add login with discord

This commit is contained in:
CounterFire2023 2024-01-24 16:12:23 +08:00
parent 3e00bfb18f
commit e8f07f028c
4 changed files with 35 additions and 8 deletions

View File

@ -372,6 +372,11 @@ void signWithEmailJNI(const std::string &funid)
JniHelper::callStaticVoidMethod(JCSDK, "signWithEmail", funid);
}
void signWithDiscordJNI(const std::string &funid)
{
JniHelper::callStaticVoidMethod(JCSDK, "signWithDiscord", funid);
}
void callJcVoidMethodJNI(const std::string &funid, const std::string &method_name)
{
JniHelper::callStaticVoidMethod(JCSDK, method_name, funid);

View File

@ -45,6 +45,7 @@ void signOutGoogleJNI(const std::string &funid);
void signWithFacebookJNI(const std::string &funid);
void signWithTwitterJNI(const std::string &funid);
void signWithEmailJNI(const std::string &funid);
void signWithDiscordJNI(const std::string &funid);
void callJcVoidMethodJNI(const std::string &funid, const std::string &method_name);
void toWalletJNI(const std::string &url);
void beginBuyJNI(const std::string &funid, const std::string &productid, const std::string &orderid);

View File

@ -138,10 +138,7 @@ namespace
[self stopMainLoop];
_displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(doCaller:)];
if (_systemVersion >= 10.0f)
[_displayLink setPreferredFramesPerSecond: _fps];
else
[_displayLink setFrameInterval: 60 / _fps];
[_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}
@ -263,7 +260,7 @@ bool Application::isDisplayStats() {
void Application::setDisplayStats(bool isShow) {
se::AutoHandleScope hs;
char commandBuf[100] = {0};
sprintf(commandBuf, "cc.debug.setDisplayStats(%s);", isShow ? "true" : "false");
snprintf(commandBuf, isShow ? 31 : 32, "cc.debug.setDisplayStats(%s);", isShow ? "true" : "false");
se::ScriptEngine::getInstance()->evalString(commandBuf);
}
@ -322,7 +319,12 @@ bool Application::openURL(const std::string &url)
{
NSString* msg = [NSString stringWithCString:url.c_str() encoding:NSUTF8StringEncoding];
NSURL* nsUrl = [NSURL URLWithString:msg];
return [[UIApplication sharedApplication] openURL:nsUrl];
[[UIApplication sharedApplication] openURL:nsUrl options:@{} completionHandler:^(BOOL success) {
if (success) {
NSLog(@"Opened url");
}
}];
return true;
}
void Application::copyTextToClipboard(const std::string &text)

View File

@ -969,6 +969,24 @@ static bool JSB_signWithEmail(se::State &s)
}
SE_BIND_FUNC(JSB_signWithEmail)
static bool JSB_signWithDiscord(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!");
signWithDiscordJNI(funid);
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
return false;
}
SE_BIND_FUNC(JSB_signWithDiscord)
static bool JSB_callJcVoidMethodJNI(se::State &s)
{
const auto &args = s.args();
@ -1702,6 +1720,7 @@ bool jsb_register_global_variables(se::Object *global)
__jsbObj->defineFunction("signWithFacebook", _SE(JSB_signWithFacebook));
__jsbObj->defineFunction("signWithTwitter", _SE(JSB_signWithTwitter));
__jsbObj->defineFunction("signWithEmail", _SE(JSB_signWithEmail));
__jsbObj->defineFunction("signWithDiscord", _SE(JSB_signWithDiscord));
__jsbObj->defineFunction("callJcVoidMethodJNI", _SE(JSB_callJcVoidMethodJNI));
__jsbObj->defineFunction("signOutGoogle", _SE(JSB_signOutGoogle));
__jsbObj->defineFunction("showQRCode", _SE(JSB_showQRCode));