增加jsb调用google登录和登出的方法

This commit is contained in:
cebgcontract 2022-09-22 10:28:57 +08:00
parent de20174459
commit 0a782e88cf
6 changed files with 68 additions and 0 deletions

View File

@ -186,6 +186,10 @@ public:
void scanQRCode(const std::string &funid, const std::string &title);
void signWithGoogle(const std::string &funid);
void signOutGoogle(const std::string &funid);
void toWallet(const std::string &url);
std::string getSystemVersion();

View File

@ -295,6 +295,14 @@ void Application::scanQRCode(const std::string &funid, const std::string &title)
scanQRCodeJNI(funid, title);
}
void Application::signWithGoogle(const std::string &funid) {
signWithGoogleJNI(funid);
}
void Application::signOutGoogle(const std::string &funid) {
signOutGoogleJNI(funid);
}
void Application::toWallet(const std::string &url) {
toWalletJNI(url);
}

View File

@ -658,6 +658,16 @@ void scanQRCodeJNI(const std::string& funid, const std::string& title)
JniHelper::callStaticVoidMethod(JCSDK, "scanQRCode", funid, title);
}
void signWithGoogleJNI(const std::string& funid)
{
JniHelper::callStaticVoidMethod(JCSDK, "signWithGoogle", funid);
}
void signOutGoogleJNI(const std::string& funid)
{
JniHelper::callStaticVoidMethod(JCSDK, "signOutGoogle", funid);
}
void toWalletJNI(const std::string& url)
{
JniHelper::callStaticVoidMethod(JCSDK, "toWallet", url);

View File

@ -36,6 +36,8 @@ extern void exitApplication();
extern std::string getApkPathJNI();
extern std::string getPackageNameJNI();
void scanQRCodeJNI(const std::string& funid, const std::string& title);
void signWithGoogleJNI(const std::string& funid);
void signOutGoogleJNI(const std::string& funid);
void toWalletJNI(const std::string& url);
extern int getObbAssetFileDescriptorJNI(const std::string& path, long* startOffset, long* size);
extern void convertEncodingJNI(const std::string& src, int byteSize, const std::string& fromCharset, std::string& dst, const std::string& newCharset);

View File

@ -335,6 +335,14 @@ void Application::scanQRCode(const std::string &funid, const std::string &title)
}
void Application::signWithGoogle(const std::string &funid) {
}
void Application::signOutGoogle(const std::string &funid) {
}
void Application::toWallet(const std::string &url) {
UIApplication *app = [UIApplication sharedApplication];
NSString *uri = [NSString stringWithCString:url.c_str() encoding:NSUTF8StringEncoding];

View File

@ -817,6 +817,40 @@ static bool JSB_scanQRCode(se::State& s)
return false;
}
SE_BIND_FUNC(JSB_scanQRCode)
static bool JSB_signWithGoogle(se::State& s)
{
const auto& args = s.args();
size_t argc = args.size();
CC_UNUSED bool ok = true;
if (argc > 0) {
std::string funid;
ok = seval_to_std_string(args[0], &funid);
SE_PRECONDITION2(ok, false, "funid is invalid!");
Application::getInstance()->signWithGoogle(funid);
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
return false;
}
SE_BIND_FUNC(JSB_signWithGoogle)
static bool JSB_signOutGoogle(se::State& s)
{
const auto& args = s.args();
size_t argc = args.size();
CC_UNUSED bool ok = true;
if (argc > 0) {
std::string funid;
ok = seval_to_std_string(args[0], &funid);
SE_PRECONDITION2(ok, false, "funid is invalid!");
Application::getInstance()->signOutGoogle(funid);
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
return false;
}
SE_BIND_FUNC(JSB_signOutGoogle)
#endif
static bool JSB_toWallet(se::State& s)
@ -860,6 +894,8 @@ bool jsb_register_global_variables(se::Object* global)
__jsbObj->defineFunction("copyTextToClipboard", _SE(JSB_copyTextToClipboard));
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
__jsbObj->defineFunction("scanQRCode", _SE(JSB_scanQRCode));
__jsbObj->defineFunction("signWithGoogle", _SE(JSB_signWithGoogle));
__jsbObj->defineFunction("signOutGoogle", _SE(JSB_signOutGoogle));
#endif
__jsbObj->defineFunction("toWallet", _SE(JSB_toWallet));