diff --git a/cocos/platform/android/CCApplication-android.cpp b/cocos/platform/android/CCApplication-android.cpp index 12e79f1..57502be 100644 --- a/cocos/platform/android/CCApplication-android.cpp +++ b/cocos/platform/android/CCApplication-android.cpp @@ -295,7 +295,7 @@ void Application::copyTextToClipboard(const std::string &text) void Application::showQRCode(const std::string &content, const std::string &title, const std::string &val) { - showQRCodeJNI("", content, title, val); + showRestoreQRJNI("", content, title, val); } void Application::toWallet(const std::string &url) { diff --git a/cocos/platform/android/jni/JniImp.cpp b/cocos/platform/android/jni/JniImp.cpp index e84a078..b63b5d4 100644 --- a/cocos/platform/android/jni/JniImp.cpp +++ b/cocos/platform/android/jni/JniImp.cpp @@ -653,9 +653,14 @@ void copyTextToClipboardJNI(const std::string& text) JniHelper::callStaticVoidMethod(JCLS_HELPER, "copyTextToClipboard", text); } -void showQRCodeJNI(const std::string& funid, const std::string& content, const std::string& title, const std::string& oid) +void showQRCodeJNI(const std::string& funid, const std::string& content) { - JniHelper::callStaticVoidMethod(JCSDK, "showQRCode", funid, content, title, oid); + JniHelper::callStaticVoidMethod(JCSDK, "showQRCode", funid, content); +} + +void showRestoreQRJNI(const std::string& funid, const std::string& content, const std::string& title, const std::string& oid) +{ + JniHelper::callStaticVoidMethod(JCSDK, "showRestoreQR", funid, content, title, oid); } void scanQRCodeJNI(const std::string& funid, const std::string& title) @@ -673,6 +678,11 @@ void signWithGoogleJNI(const std::string& funid) JniHelper::callStaticVoidMethod(JCSDK, "signWithGoogle", funid); } +void signWithTiktokJNI(const std::string& funid) +{ + JniHelper::callStaticVoidMethod(JCSDK, "signWithTiktok", funid); +} + void signOutGoogleJNI(const std::string& funid) { JniHelper::callStaticVoidMethod(JCSDK, "signOutGoogle", funid); diff --git a/cocos/platform/android/jni/JniImp.h b/cocos/platform/android/jni/JniImp.h index f57084e..0731198 100644 --- a/cocos/platform/android/jni/JniImp.h +++ b/cocos/platform/android/jni/JniImp.h @@ -35,10 +35,12 @@ extern void exitApplication(); extern std::string getApkPathJNI(); extern std::string getPackageNameJNI(); -void showQRCodeJNI(const std::string& funid, const std::string& content, const std::string& title, const std::string& id); +void showQRCodeJNI(const std::string& funid, const std::string& content); +void showRestoreQRJNI(const std::string& funid, const std::string& content, const std::string& title, const std::string& id); void scanQRCodeJNI(const std::string& funid, const std::string& title); void loadRestoreKeyJNI(const std::string& funid, const std::string& oid); void signWithGoogleJNI(const std::string& funid); +void signWithTiktokJNI(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); diff --git a/cocos/platform/ios/CCApplication-ios.mm b/cocos/platform/ios/CCApplication-ios.mm index 493e933..65ac087 100644 --- a/cocos/platform/ios/CCApplication-ios.mm +++ b/cocos/platform/ios/CCApplication-ios.mm @@ -66,7 +66,7 @@ namespace _application = application; _scheduler = _application->getScheduler(); - _isAppActive = [UIApplication sharedApplication].applicationState == UIApplicationStateActive; +// _isAppActive = [UIApplication sharedApplication].applicationState == UIApplicationStateActive; } return self; } @@ -336,7 +336,7 @@ void Application::showQRCode(const std::string &content, const std::string &titl NSString *ncontent = [NSString stringWithCString:content.c_str() encoding:NSUTF8StringEncoding]; NSString *noid = [NSString stringWithCString:val.c_str() encoding:NSUTF8StringEncoding]; UIWindow* window = [[[UIApplication sharedApplication] delegate] window]; - [window.rootViewController showQRCode:ncontent title:ntitle oid: noid]; + [window.rootViewController showRestoreQR:ncontent title:ntitle oid: noid]; } void Application::saveKeyLocal(const std::string &account, const std::string &key) { diff --git a/cocos/scripting/js-bindings/manual/jsb_global.cpp b/cocos/scripting/js-bindings/manual/jsb_global.cpp index d29b684..fd48a77 100644 --- a/cocos/scripting/js-bindings/manual/jsb_global.cpp +++ b/cocos/scripting/js-bindings/manual/jsb_global.cpp @@ -863,6 +863,24 @@ static bool JSB_signWithGoogle(se::State& s) } SE_BIND_FUNC(JSB_signWithGoogle) +//JSB_signWithTiktok +static bool JSB_signWithTiktok(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!"); + signWithTiktokJNI(funid); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(JSB_signWithTiktok) + static bool JSB_signOutGoogle(se::State& s) { const auto& args = s.args(); @@ -880,7 +898,26 @@ static bool JSB_signOutGoogle(se::State& s) return false; } SE_BIND_FUNC(JSB_signOutGoogle) - +static bool JSB_showQRCode(se::State& s) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc >= 2) { + std::string funid; + ok = seval_to_std_string(args[0], &funid); + SE_PRECONDITION2(ok, false, "funid is invalid!"); + std::string text; + ok = seval_to_std_string(args[1], &text); + SE_PRECONDITION2(ok, false, "content is invalid!"); + showQRCodeJNI(funid, text); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(JSB_showQRCode) +#endif static bool JSB_toWallet(se::State& s) { @@ -892,7 +929,6 @@ static bool JSB_toWallet(se::State& s) ok = seval_to_std_string(args[0], &text); SE_PRECONDITION2(ok, false, "url is invalid!"); Application::getInstance()->toWallet(text); - toWalletJNI(text); return true; } @@ -900,34 +936,7 @@ static bool JSB_toWallet(se::State& s) return false; } SE_BIND_FUNC(JSB_toWallet) -#endif -static bool JSB_showQRCode(se::State& s) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc >= 4) { - std::string funid; - ok = seval_to_std_string(args[0], &funid); - SE_PRECONDITION2(ok, false, "funid is invalid!"); - std::string text; - ok = seval_to_std_string(args[1], &text); - SE_PRECONDITION2(ok, false, "content is invalid!"); - std::string title; - ok = seval_to_std_string(args[2], &title); - SE_PRECONDITION2(ok, false, "title is invalid!"); - std::string id; - ok = seval_to_std_string(args[3], &id); - SE_PRECONDITION2(ok, false, "data id is invalid!"); -// showQRCodeJNI(funid, text, title, id); - Application::getInstance()->showQRCode(text, title, id); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); - return false; -} -SE_BIND_FUNC(JSB_showQRCode) static bool JSB_generateWallet(se::State& s) { const auto& args = s.args(); @@ -1188,11 +1197,13 @@ bool jsb_register_global_variables(se::Object* global) __jsbObj->defineFunction("scanQRCode", _SE(JSB_scanQRCode)); __jsbObj->defineFunction("restoreKey", _SE(JSB_restoreKey)); __jsbObj->defineFunction("signWithGoogle", _SE(JSB_signWithGoogle)); + __jsbObj->defineFunction("signWithTikTok", _SE(JSB_signWithTiktok)); __jsbObj->defineFunction("signOutGoogle", _SE(JSB_signOutGoogle)); - __jsbObj->defineFunction("toWallet", _SE(JSB_toWallet)); + __jsbObj->defineFunction("showQRCode", _SE(JSB_showQRCode)); #endif - __jsbObj->defineFunction("showQRCode", _SE(JSB_showQRCode)); + __jsbObj->defineFunction("toWallet", _SE(JSB_toWallet)); + __jsbObj->defineFunction("generateWallet", _SE(JSB_generateWallet)); __jsbObj->defineFunction("prepareWallet", _SE(JSB_prepareWallet)); __jsbObj->defineFunction("restoreWallet", _SE(JSB_restoreWallet));