add login for tiktok
This commit is contained in:
parent
2aacd20379
commit
42dd1c98e3
@ -38,6 +38,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
#import <TikTokOpenSDK/TikTokOpenSDKApplicationDelegate.h>
|
||||||
|
|
||||||
|
|
||||||
// we assume that app delegate is never changed and we can cache it, instead of re-query UIApplication every time
|
// we assume that app delegate is never changed and we can cache it, instead of re-query UIApplication every time
|
||||||
@ -243,6 +244,21 @@ extern "C" void UnityRequestQuit()
|
|||||||
if (annotation) notifData[@"annotation"] = annotation;
|
if (annotation) notifData[@"annotation"] = annotation;
|
||||||
|
|
||||||
AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);
|
AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);
|
||||||
|
|
||||||
|
[[TikTokOpenSDKApplicationDelegate sharedInstance] application:app openURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for tiktok
|
||||||
|
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
|
||||||
|
{
|
||||||
|
[[TikTokOpenSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
|
||||||
|
{
|
||||||
|
[[TikTokOpenSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:nil annotation:nil];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,6 +305,7 @@ extern "C" void UnityRequestQuit()
|
|||||||
g.delaysTouchesBegan = false;
|
g.delaysTouchesBegan = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
[[TikTokOpenSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,8 +291,10 @@ bool jsb_scanQRCode(se::State& s) {
|
|||||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||||
NSString *ntitle = [NSString stringWithCString:title.c_str() encoding:NSUTF8StringEncoding];
|
NSString *ntitle = [NSString stringWithCString:title.c_str() encoding:NSUTF8StringEncoding];
|
||||||
NSString *nfunid = [NSString stringWithCString:funid.c_str() encoding:NSUTF8StringEncoding];
|
NSString *nfunid = [NSString stringWithCString:funid.c_str() encoding:NSUTF8StringEncoding];
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
|
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
|
||||||
[window.rootViewController scanQRCode:nfunid title:ntitle];
|
[window.rootViewController scanQRCode:nfunid title:ntitle];
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -314,8 +316,10 @@ bool JSB_restoreKey(se::State& s)
|
|||||||
SE_PRECONDITION2(ok, false, "oid is invalid!");
|
SE_PRECONDITION2(ok, false, "oid is invalid!");
|
||||||
NSString *nfunid = [NSString stringWithCString:funid.c_str() encoding:NSUTF8StringEncoding];
|
NSString *nfunid = [NSString stringWithCString:funid.c_str() encoding:NSUTF8StringEncoding];
|
||||||
NSString *noid = [NSString stringWithCString:oid.c_str() encoding:NSUTF8StringEncoding];
|
NSString *noid = [NSString stringWithCString:oid.c_str() encoding:NSUTF8StringEncoding];
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
|
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
|
||||||
[window.rootViewController loadRestoreKey:nfunid oid: noid];
|
[window.rootViewController loadRestoreKey:nfunid oid: noid];
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2);
|
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2);
|
||||||
@ -332,8 +336,10 @@ bool jsb_signWithGoogle(se::State& s) {
|
|||||||
ok = seval_to_std_string(args[0], &funid);
|
ok = seval_to_std_string(args[0], &funid);
|
||||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||||
NSString *nfunid = [NSString stringWithCString:funid.c_str() encoding:NSUTF8StringEncoding];
|
NSString *nfunid = [NSString stringWithCString:funid.c_str() encoding:NSUTF8StringEncoding];
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
|
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
|
||||||
[window.rootViewController signWithGoogle:nfunid];
|
[window.rootViewController signWithGoogle:nfunid];
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -349,14 +355,35 @@ bool jsb_signWithApple(se::State& s) {
|
|||||||
ok = seval_to_std_string(args[0], &funid);
|
ok = seval_to_std_string(args[0], &funid);
|
||||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||||
NSString *nfunid = [NSString stringWithCString:funid.c_str() encoding:NSUTF8StringEncoding];
|
NSString *nfunid = [NSString stringWithCString:funid.c_str() encoding:NSUTF8StringEncoding];
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
|
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
|
||||||
[window.rootViewController signWithApple:nfunid];
|
[window.rootViewController signWithApple:nfunid];
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SE_BIND_FUNC(jsb_signWithApple)
|
SE_BIND_FUNC(jsb_signWithApple)
|
||||||
|
|
||||||
|
bool jsb_signWithTikTok(se::State& s) {
|
||||||
|
const auto& args = s.args();
|
||||||
|
size_t argc = args.size();
|
||||||
|
if (argc >= 1) {
|
||||||
|
bool ok;
|
||||||
|
std::string funid;
|
||||||
|
ok = seval_to_std_string(args[0], &funid);
|
||||||
|
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||||
|
NSString *nfunid = [NSString stringWithCString:funid.c_str() encoding:NSUTF8StringEncoding];
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
|
||||||
|
[window.rootViewController signWithTikTok:nfunid];
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SE_BIND_FUNC(jsb_signWithTikTok)
|
||||||
|
|
||||||
bool jsb_signOutGoogle(se::State& s) {
|
bool jsb_signOutGoogle(se::State& s) {
|
||||||
const auto& args = s.args();
|
const auto& args = s.args();
|
||||||
size_t argc = args.size();
|
size_t argc = args.size();
|
||||||
@ -366,8 +393,10 @@ bool jsb_signOutGoogle(se::State& s) {
|
|||||||
ok = seval_to_std_string(args[0], &funid);
|
ok = seval_to_std_string(args[0], &funid);
|
||||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||||
NSString *nfunid = [NSString stringWithCString:funid.c_str() encoding:NSUTF8StringEncoding];
|
NSString *nfunid = [NSString stringWithCString:funid.c_str() encoding:NSUTF8StringEncoding];
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
|
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
|
||||||
[window.rootViewController signOutGoogle:nfunid];
|
[window.rootViewController signWithTikTok:nfunid];
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -382,6 +411,7 @@ bool jsb_register_walletevent_modules(se::Object* global) {
|
|||||||
__jsbObj->defineFunction("restoreKey", _SE(JSB_restoreKey));
|
__jsbObj->defineFunction("restoreKey", _SE(JSB_restoreKey));
|
||||||
__jsbObj->defineFunction("signWithGoogle", _SE(jsb_signWithGoogle));
|
__jsbObj->defineFunction("signWithGoogle", _SE(jsb_signWithGoogle));
|
||||||
__jsbObj->defineFunction("signWithApple", _SE(jsb_signWithApple));
|
__jsbObj->defineFunction("signWithApple", _SE(jsb_signWithApple));
|
||||||
|
__jsbObj->defineFunction("signWithTikTok", _SE(jsb_signWithTikTok));
|
||||||
__jsbObj->defineFunction("signOutGoogle", _SE(jsb_signOutGoogle));
|
__jsbObj->defineFunction("signOutGoogle", _SE(jsb_signOutGoogle));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
+(void)toWallet:(NSString *)url;
|
+(void)toWallet:(NSString *)url;
|
||||||
-(void)signWithGoogle:(NSString *)funid;
|
-(void)signWithGoogle:(NSString *)funid;
|
||||||
-(void)signWithApple:(NSString *)funid;
|
-(void)signWithApple:(NSString *)funid;
|
||||||
|
-(void)signWithTikTok:(NSString *)funid;
|
||||||
-(void)signOutGoogle:(NSString *)funid;
|
-(void)signOutGoogle:(NSString *)funid;
|
||||||
-(void)saveKey:(NSString *) account key:(NSString *) key;
|
-(void)saveKey:(NSString *) account key:(NSString *) key;
|
||||||
-(NSString *)loadKey:(NSString *) account;
|
-(NSString *)loadKey:(NSString *) account;
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#import "UIViewController+Wallet.h"
|
#import "UIViewController+Wallet.h"
|
||||||
|
|
||||||
|
#import <TikTokOpenSDK/TikTokOpenSDKAuth.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "WalletEvent.h"
|
#include "WalletEvent.h"
|
||||||
#include "JcWallet.h"
|
#include "JcWallet.h"
|
||||||
@ -108,6 +110,32 @@ static NSString * const kClientID =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark -- Sign In with TikTok
|
||||||
|
- (void) signWithTikTok:(NSString *) funid {
|
||||||
|
/* STEP 1: Create the request and set permissions */
|
||||||
|
NSArray *scopes = [NSArray arrayWithObjects: @"user.info.basic,video.list", nil]; // list your scopes;
|
||||||
|
NSOrderedSet *scopesSet = [NSOrderedSet orderedSetWithArray:scopes];
|
||||||
|
TikTokOpenSDKAuthRequest *request = [[TikTokOpenSDKAuthRequest alloc] init];
|
||||||
|
request.permissions = scopesSet;
|
||||||
|
|
||||||
|
/* STEP 2: Send the request */
|
||||||
|
__weak typeof(self) ws = self;
|
||||||
|
[request sendAuthRequestViewController:self
|
||||||
|
completion:^(TikTokOpenSDKAuthResponse *_Nonnull resp) {
|
||||||
|
__strong typeof(ws) sf = ws;
|
||||||
|
|
||||||
|
/* STEP 3: Parse and handle the response */
|
||||||
|
if (resp.errCode == 0) {
|
||||||
|
NSString *responseCode = resp.code;
|
||||||
|
// Upload response code to your server and obtain user access token
|
||||||
|
NSLog(@"tiktok resp: %@", responseCode);
|
||||||
|
} else {
|
||||||
|
// User authorization failed. Handle errors
|
||||||
|
NSLog(@"tiktok resp error: %@", resp.description);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
-(void)nativeCb:(NSString *)funid hasErr: (BOOL) hasErr dataStr:(NSString *) dataStr {
|
-(void)nativeCb:(NSString *)funid hasErr: (BOOL) hasErr dataStr:(NSString *) dataStr {
|
||||||
if ([NSString isStringEmpty:funid]) {
|
if ([NSString isStringEmpty:funid]) {
|
||||||
|
23
Info.plist
23
Info.plist
@ -2,8 +2,6 @@
|
|||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSPhotoLibraryUsageDescription</key>
|
|
||||||
<string>Restore Wallet recovery key need Photo Libray</string>
|
|
||||||
<key>CADisableMinimumFrameDuration</key>
|
<key>CADisableMinimumFrameDuration</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
@ -25,8 +23,12 @@
|
|||||||
<key>CFBundleURLTypes</key>
|
<key>CFBundleURLTypes</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeRole</key>
|
<key>CFBundleURLSchemes</key>
|
||||||
<string>Editor</string>
|
<array>
|
||||||
|
<string>7168682541145278470</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
<key>CFBundleURLSchemes</key>
|
<key>CFBundleURLSchemes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>com.googleusercontent.apps.53206975661-0d6q9pqljn84n9l63gm0to1ulap9cbk4</string>
|
<string>com.googleusercontent.apps.53206975661-0d6q9pqljn84n9l63gm0to1ulap9cbk4</string>
|
||||||
@ -35,6 +37,13 @@
|
|||||||
</array>
|
</array>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>0</string>
|
<string>0</string>
|
||||||
|
<key>LSApplicationQueriesSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>tiktokopensdk</string>
|
||||||
|
<string>tiktoksharesdk</string>
|
||||||
|
<string>snssdk1180</string>
|
||||||
|
<string>snssdk1233</string>
|
||||||
|
</array>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSAppTransportSecurity</key>
|
<key>NSAppTransportSecurity</key>
|
||||||
@ -44,6 +53,10 @@
|
|||||||
</dict>
|
</dict>
|
||||||
<key>NSCameraUsageDescription</key>
|
<key>NSCameraUsageDescription</key>
|
||||||
<string>The camera is need to scan QR codes</string>
|
<string>The camera is need to scan QR codes</string>
|
||||||
|
<key>NSPhotoLibraryUsageDescription</key>
|
||||||
|
<string>Restore Wallet recovery key need Photo Libray</string>
|
||||||
|
<key>TikTokAppID</key>
|
||||||
|
<string>7168682541145278470</string>
|
||||||
<key>UIApplicationExitsOnSuspend</key>
|
<key>UIApplicationExitsOnSuspend</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>UILaunchStoryboardName~ipad</key>
|
<key>UILaunchStoryboardName~ipad</key>
|
||||||
@ -56,7 +69,7 @@
|
|||||||
<false/>
|
<false/>
|
||||||
<key>UIRequiredDeviceCapabilities</key>
|
<key>UIRequiredDeviceCapabilities</key>
|
||||||
<array>
|
<array>
|
||||||
<string>armv7</string>
|
<string>arm64</string>
|
||||||
</array>
|
</array>
|
||||||
<key>UIRequiresFullScreen</key>
|
<key>UIRequiresFullScreen</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
1
Podfile
1
Podfile
@ -3,4 +3,5 @@ use_frameworks!
|
|||||||
|
|
||||||
target 'Unity-iPhone' do
|
target 'Unity-iPhone' do
|
||||||
pod 'GoogleSignIn', :path => '/Users/zhl/Downloads/sourcecode/google/GoogleSignIn-iOS/'
|
pod 'GoogleSignIn', :path => '/Users/zhl/Downloads/sourcecode/google/GoogleSignIn-iOS/'
|
||||||
|
pod 'TikTokOpenSDK', '~> 5.0.14'
|
||||||
end
|
end
|
||||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -100,5 +100,101 @@
|
|||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
uuid = "7F7312BF-4E29-4C33-8BF4-8D00ADA72A88"
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Classes_cocos/UIViewController+Wallet.mm"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "128"
|
||||||
|
endingLineNumber = "128"
|
||||||
|
landmarkName = "-signWithTikTok:"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
uuid = "436E79B4-8769-4CAF-9B57-CE0E3D8D5AFF"
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Classes_cocos/UIViewController+Wallet.mm"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "134"
|
||||||
|
endingLineNumber = "134"
|
||||||
|
landmarkName = "-signWithTikTok:"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
uuid = "79E256FF-FD49-47A5-BFAE-26D14EFA1DB6"
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Classes/UnityAppController.mm"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "255"
|
||||||
|
endingLineNumber = "255"
|
||||||
|
landmarkName = "UnityAppController"
|
||||||
|
landmarkType = "3">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
uuid = "A1445887-A4BB-41E7-A04A-1B36F17FF535"
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Classes/UnityAppController.mm"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "248"
|
||||||
|
endingLineNumber = "248"
|
||||||
|
landmarkName = "-application:openURL:options:"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
uuid = "A56931E1-E34B-494D-91D8-C297EC6C5AC7"
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Classes/UnityAppController.mm"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "239"
|
||||||
|
endingLineNumber = "239"
|
||||||
|
landmarkName = "-application:openURL:options:"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
uuid = "4AB36A93-5471-4274-9346-7A357FE914BD"
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Classes/UnityAppController.mm"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "308"
|
||||||
|
endingLineNumber = "308"
|
||||||
|
landmarkName = "-application:didFinishLaunchingWithOptions:"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
</Breakpoints>
|
</Breakpoints>
|
||||||
</Bucket>
|
</Bucket>
|
||||||
|
File diff suppressed because one or more lines are too long
221
js/main.js
221
js/main.js
@ -8,15 +8,13 @@ console.log(">>begin load wallet main file");
|
|||||||
function initWallet(funId, type, chain, channel) {
|
function initWallet(funId, type, chain, channel) {
|
||||||
type = parseInt(type)
|
type = parseInt(type)
|
||||||
chain = parseInt(chain)
|
chain = parseInt(chain)
|
||||||
channel = channel || 0;
|
channel = channel || 2; // 0:google, 1: apple, 2: tiktok
|
||||||
channel = parseInt(channel);
|
channel = parseInt(channel);
|
||||||
|
console.log(`initWallet:: type: ${type}, chain: ${chain}, channel: ${channel}`)
|
||||||
try {
|
try {
|
||||||
var wallet;
|
let wallet;
|
||||||
if (!window.jc || !jc.wallet) {
|
if (!window.jc || !jc.wallet) {
|
||||||
wallet = new jcwallet.default({
|
wallet = new jcwallet.default({ chain, type });
|
||||||
chain,
|
|
||||||
type
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
wallet = jc.wallet;
|
wallet = jc.wallet;
|
||||||
}
|
}
|
||||||
@ -27,7 +25,7 @@ function initWallet(funId, type, chain, channel) {
|
|||||||
.initThirdPartyWallet()
|
.initThirdPartyWallet()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log("walletconnect connect success");
|
console.log("walletconnect connect success");
|
||||||
var account = jc.wallet.currentAccount();
|
let account = jc.wallet.currentAccount();
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: account}));
|
jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: account}));
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@ -38,7 +36,7 @@ function initWallet(funId, type, chain, channel) {
|
|||||||
wallet.initInternalWallet(channel)
|
wallet.initInternalWallet(channel)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log("internal init success");
|
console.log("internal init success");
|
||||||
var address = jc.wallet.nativeAccount;
|
let address = jc.wallet.nativeAccount;
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: address}));
|
jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: address}));
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@ -58,37 +56,21 @@ function initWallet(funId, type, chain, channel) {
|
|||||||
function currentAccount(funId) {
|
function currentAccount(funId) {
|
||||||
try {
|
try {
|
||||||
let data = jc.wallet.currentAccountData;
|
let data = jc.wallet.currentAccountData;
|
||||||
return JSON.stringify({errcode: 0,data});
|
return JSON.stringify({errcode: 0, data});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return JSON.stringify({errcode: 1, errmsg: err});
|
return JSON.stringify({errcode: 1, errmsg: err});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* all account for internal wallet
|
|
||||||
*/
|
|
||||||
function accountList(funId) {
|
|
||||||
try {
|
|
||||||
let data = jc.wallet.accounts;
|
|
||||||
return JSON.stringify({errcode: 0,data});
|
|
||||||
} catch (err) {
|
|
||||||
return JSON.stringify({
|
|
||||||
errcode: 1,
|
|
||||||
errmsg: err,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* all chain list we supported
|
* all chain list we supported
|
||||||
*/
|
*/
|
||||||
function chainList(funId) {
|
function chainList(funId) {
|
||||||
try {
|
try {
|
||||||
let data = jc.wallet.chainList;
|
let data = jc.wallet.chainList;
|
||||||
return JSON.stringify({errcode: 0,data});
|
return JSON.stringify({errcode: 0, data});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return JSON.stringify({
|
return JSON.stringify({ errcode: 1, errmsg: err });
|
||||||
errcode: 1,
|
|
||||||
errmsg: err,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -109,15 +91,14 @@ function currentChain(funId) {
|
|||||||
* [BOTH]change chain
|
* [BOTH]change chain
|
||||||
*/
|
*/
|
||||||
function changeChain(funId, chainId) {
|
function changeChain(funId, chainId) {
|
||||||
// chainId = parseInt(chainId);
|
chainId = parseInt(chainId);
|
||||||
chainId = 80001;
|
|
||||||
jc.wallet
|
jc.wallet
|
||||||
.updateCurrentChain(chainId)
|
.updateCurrentChain(chainId)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: result}));
|
jsb.jcCallback(funId, JSON.stringify({ errcode: 0,data: result }));
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
jsb.jcCallback(funId,JSON.stringify({ errcode: 1,errmsg: err }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -129,87 +110,23 @@ function loginSign(funId, nonce, tips) {
|
|||||||
jc.wallet
|
jc.wallet
|
||||||
.loginSign(nonce, tips)
|
.loginSign(nonce, tips)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
jsb.jcCallback(
|
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
|
||||||
funId,
|
|
||||||
JSON.stringify({
|
|
||||||
errcode: 0,
|
|
||||||
data: result,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
jsb.jcCallback(funId, JSON.stringify({errcode: 1,errmsg: err }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* add one new account, then active this account
|
|
||||||
* @return {string} account actived
|
|
||||||
*/
|
|
||||||
function createAccount(funId) {
|
|
||||||
try {
|
|
||||||
let result = jc.wallet.createAccount();
|
|
||||||
return JSON.stringify({
|
|
||||||
errcode: 0,
|
|
||||||
data: result,
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
return JSON.stringify({
|
|
||||||
errcode: 1,
|
|
||||||
errmsg: err,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* import account with private key
|
|
||||||
* @return {string} account actived
|
|
||||||
*/
|
|
||||||
function importAccount(funId, privateKey) {
|
|
||||||
try {
|
|
||||||
let address = jc.wallet.importAccount(privateKey);
|
|
||||||
return JSON.stringify({
|
|
||||||
errcode: 0,
|
|
||||||
data: address,
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
return JSON.stringify({
|
|
||||||
errcode: 1,
|
|
||||||
errmsg: err,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* active one account
|
|
||||||
*/
|
|
||||||
function selectAccount(funId, address) {
|
|
||||||
try {
|
|
||||||
let result = jc.wallet.selectAccount(address);
|
|
||||||
return JSON.stringify({
|
|
||||||
errcode: 0,
|
|
||||||
data: result,
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
return JSON.stringify({
|
|
||||||
errcode: 1,
|
|
||||||
errmsg: err,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* get balance of ETH
|
* get balance of ETH
|
||||||
* @param {string} address: account
|
* @param {string} account: account
|
||||||
* if account is null, we`ll query for current account of wallet
|
* if account is null, we`ll query for current account of wallet
|
||||||
*/
|
*/
|
||||||
function getEthBalance(funId, address) {
|
function getEthBalance(funId, account) {
|
||||||
jc.wallet
|
jc.wallet
|
||||||
.getBalance(address)
|
.getBalance(account)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
jsb.jcCallback(
|
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
|
||||||
funId,
|
|
||||||
JSON.stringify({
|
|
||||||
errcode: 0,
|
|
||||||
data: result,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||||
@ -224,13 +141,7 @@ function sendEth(funId, to, amount) {
|
|||||||
jc.wallet
|
jc.wallet
|
||||||
.sendEth(to, amount)
|
.sendEth(to, amount)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
jsb.jcCallback(
|
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
|
||||||
funId,
|
|
||||||
JSON.stringify({
|
|
||||||
errcode: 0,
|
|
||||||
data: result,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||||
@ -246,15 +157,9 @@ function generateIcon(funId, msg, diameter) {
|
|||||||
try {
|
try {
|
||||||
diameter = parseFloat(diameter);
|
diameter = parseFloat(diameter);
|
||||||
let result = jc.wallet.generateIconData(msg, diameter);
|
let result = jc.wallet.generateIconData(msg, diameter);
|
||||||
return JSON.stringify({
|
return JSON.stringify({ errcode: 0, data: result });
|
||||||
errcode: 0,
|
|
||||||
data: result,
|
|
||||||
});
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return JSON.stringify({
|
return JSON.stringify({ errcode: 1, errmsg: err });
|
||||||
errcode: 1,
|
|
||||||
errmsg: err,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,13 +171,7 @@ function erc20Info(funId, address) {
|
|||||||
jc.wallet
|
jc.wallet
|
||||||
.erc20Info(address)
|
.erc20Info(address)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
jsb.jcCallback(
|
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
|
||||||
funId,
|
|
||||||
JSON.stringify({
|
|
||||||
errcode: 0,
|
|
||||||
data: result,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||||
@ -287,13 +186,7 @@ function erc20Balance(funId, address, account) {
|
|||||||
jc.wallet
|
jc.wallet
|
||||||
.erc20Balance(address, account)
|
.erc20Balance(address, account)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
jsb.jcCallback(
|
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
|
||||||
funId,
|
|
||||||
JSON.stringify({
|
|
||||||
errcode: 0,
|
|
||||||
data: result,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||||
@ -304,81 +197,24 @@ function sendErc20(funId, address, to, amount) {
|
|||||||
jc.wallet
|
jc.wallet
|
||||||
.sendErc20(address, to, amount)
|
.sendErc20(address, to, amount)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
jsb.jcCallback(
|
jsb.jcCallback(funId, JSON.stringify({ errcode: 0, data: result }));
|
||||||
funId,
|
|
||||||
JSON.stringify({
|
|
||||||
errcode: 0,
|
|
||||||
data: result,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreFromMnemonic(funId, mnemonic, password) {
|
|
||||||
try {
|
|
||||||
let result = jc.wallet.restoreFromMnemonic(mnemonic, password);
|
|
||||||
return JSON.stringify({
|
|
||||||
errcode: 0,
|
|
||||||
data: result,
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
return JSON.stringify({
|
|
||||||
errcode: 1,
|
|
||||||
errmsg: err,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function scanQRCode(funId, title) {
|
function scanQRCode(funId, title) {
|
||||||
try {
|
try {
|
||||||
console.log('scanQRCode: ' + title)
|
console.log('scanQRCode: ' + title)
|
||||||
jsb.scanQRCode(funId, title);
|
jsb.scanQRCode(funId, title);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return JSON.stringify({
|
return JSON.stringify({ errcode: 1, errmsg: err });
|
||||||
errcode: 1,
|
|
||||||
errmsg: err,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function signWithGoogle(funId) {
|
// ======= begin of interact with contract =======
|
||||||
jc.wallet.nativeSvr.signWithGoogle(funId)
|
|
||||||
.then(res => {
|
|
||||||
console.log(`google sign result: ${typeof res}`)
|
|
||||||
console.log(res)
|
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: res}));
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.log('google sign error: ' + err);
|
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function signOutGoogle(funId) {
|
|
||||||
jc.wallet.nativeSvr.signOutGoogle(funId)
|
|
||||||
then(res => {
|
|
||||||
console.log(`google sign out result: ${typeof res}`)
|
|
||||||
console.log(res)
|
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: res}));
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.log('google sign out error: ' + err);
|
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
//function toWalletJNI(funId, url) {
|
|
||||||
// try {
|
|
||||||
// jsb.toWallet(url);
|
|
||||||
// return JSON.stringify({errcode: 0});
|
|
||||||
// } catch(err) {
|
|
||||||
// return JSON.stringify({errcode: 1, errmsg: err});
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
function buyNft721(funId, addresses, values, signature) {
|
function buyNft721(funId, addresses, values, signature) {
|
||||||
addresses = JSON.parse(addresses)
|
addresses = JSON.parse(addresses)
|
||||||
values = JSON.parse(values)
|
values = JSON.parse(values)
|
||||||
@ -628,3 +464,4 @@ function unplugChip(
|
|||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// ======= end of interact with contract =======
|
||||||
|
Loading…
x
Reference in New Issue
Block a user