优化第三方钱包的跳转
This commit is contained in:
parent
4296796411
commit
6db63f34d1
@ -80,6 +80,12 @@ bool _supportsMSAA = false;
|
|||||||
NSInteger _forceInterfaceOrientationMask = 0;
|
NSInteger _forceInterfaceOrientationMask = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@interface UnityAppController ()
|
||||||
|
@property (nonatomic, assign) UIBackgroundTaskIdentifier backgroundTaskIdentifier;
|
||||||
|
@end
|
||||||
|
static NSString *const kBgTaskName = @"cebg.AppRunInBackground";
|
||||||
|
|
||||||
|
|
||||||
@implementation UnityAppController
|
@implementation UnityAppController
|
||||||
|
|
||||||
@synthesize unityView = _unityView;
|
@synthesize unityView = _unityView;
|
||||||
@ -293,6 +299,12 @@ extern "C" void UnityRequestQuit()
|
|||||||
- (void)applicationDidEnterBackground:(UIApplication*)application
|
- (void)applicationDidEnterBackground:(UIApplication*)application
|
||||||
{
|
{
|
||||||
::printf("-> applicationDidEnterBackground()\n");
|
::printf("-> applicationDidEnterBackground()\n");
|
||||||
|
self.backgroundTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithName:kBgTaskName expirationHandler:^{
|
||||||
|
if (self.backgroundTaskIdentifier != UIBackgroundTaskInvalid) {
|
||||||
|
[[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskIdentifier];
|
||||||
|
self.backgroundTaskIdentifier = UIBackgroundTaskInvalid;
|
||||||
|
}
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillEnterForeground:(UIApplication*)application
|
- (void)applicationWillEnterForeground:(UIApplication*)application
|
||||||
@ -305,6 +317,7 @@ extern "C" void UnityRequestQuit()
|
|||||||
// if we were showing video before going to background - the view size may be changed while we are in background
|
// if we were showing video before going to background - the view size may be changed while we are in background
|
||||||
[GetAppController().unityView recreateRenderingSurfaceIfNeeded];
|
[GetAppController().unityView recreateRenderingSurfaceIfNeeded];
|
||||||
}
|
}
|
||||||
|
[[UIApplication sharedApplication] endBackgroundTask: self.backgroundTaskIdentifier];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationDidBecomeActive:(UIApplication*)application
|
- (void)applicationDidBecomeActive:(UIApplication*)application
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
<!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>UIApplicationExitsOnSuspend</key>
|
||||||
|
<false/>
|
||||||
<key>CADisableMinimumFrameDuration</key>
|
<key>CADisableMinimumFrameDuration</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
Binary file not shown.
@ -98,5 +98,85 @@
|
|||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
uuid = "ADB8CDF0-B654-4692-8623-5AC0613B9154"
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Classes/UnityAppController.mm"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "408"
|
||||||
|
endingLineNumber = "408"
|
||||||
|
landmarkName = "-applicationWillResignActive:"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
uuid = "A3DC55C3-1CB9-4E63-9F4F-6BF10B9C9F0E"
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Classes/UnityAppController.mm"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "403"
|
||||||
|
endingLineNumber = "403"
|
||||||
|
landmarkName = "-applicationWillResignActive:"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
uuid = "81607144-947B-4C43-9C64-44D7C4827382"
|
||||||
|
shouldBeEnabled = "Yes"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Classes_cocos/AppDelegate.cpp"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "83"
|
||||||
|
endingLineNumber = "83"
|
||||||
|
landmarkName = "AppDelegate::onPause()"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
uuid = "499D85CB-2D58-41E5-AB4F-66F4DC6B03A2"
|
||||||
|
shouldBeEnabled = "Yes"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Classes_cocos/AppDelegate.cpp"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "89"
|
||||||
|
endingLineNumber = "89"
|
||||||
|
landmarkName = "AppDelegate::onResume()"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
uuid = "E9A3C254-BEF5-44F3-82B9-B0303174F92F"
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Classes_cocos/JcWallet.cpp"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "159"
|
||||||
|
endingLineNumber = "159"
|
||||||
|
landmarkName = "tick(dt)"
|
||||||
|
landmarkType = "9">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
</Breakpoints>
|
</Breakpoints>
|
||||||
</Bucket>
|
</Bucket>
|
||||||
|
32
js/main.js
32
js/main.js
@ -1,27 +1,37 @@
|
|||||||
console.log('>>hi tiny wallet3')
|
console.log('>>begin load wallet main file');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化钱包, 所有操作进行前, 必须调用此方法
|
* 初始化钱包, 所有操作进行前, 必须调用此方法
|
||||||
|
* @param {string} type: 钱包类型, 0: 内置钱包, 1: 第三方钱包
|
||||||
* @param {string} password: 用于加密钱包数据的密码
|
* @param {string} password: 用于加密钱包数据的密码
|
||||||
*/
|
*/
|
||||||
function initWallet(funId, password) {
|
function initWallet(funId, type, password) {
|
||||||
try {
|
try {
|
||||||
var wallet;
|
var wallet;
|
||||||
if ( !window.jc || !jc.wallet ) {
|
if ( !window.jc || !jc.wallet ) {
|
||||||
wallet = new jcwallet.default({chain: 322, type: 1, password});
|
wallet = new jcwallet.default({chain: 322, type, password});
|
||||||
} else {
|
} else {
|
||||||
wallet = jc.wallet;
|
wallet = jc.wallet;
|
||||||
}
|
}
|
||||||
console.log('wallet inited, begin connect')
|
type = parseInt(type);
|
||||||
wallet.wConnect.connect()
|
if (type === 1) {
|
||||||
.then(() => {
|
console.log('wallet inited, begin connect')
|
||||||
console.log(' walletconnect inited')
|
wallet.wConnect.connect()
|
||||||
})
|
.then(() => {
|
||||||
// let address = jc.wallet.currentAccount().address
|
console.log('walletconnect inited')
|
||||||
return JSON.stringify({errcode: 0, data: ''});
|
var account = jc.wallet.currentAccount();
|
||||||
|
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: account}));
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err}));
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
let address = jc.wallet.currentAccount().address
|
||||||
|
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: address}));
|
||||||
|
}
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.error('error init wallet: ' + JSON.stringify(err));
|
console.error('error init wallet: ' + JSON.stringify(err));
|
||||||
return JSON.stringify({errcode: 1, errmsg: err});
|
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -8,11 +8,9 @@ window.jumpToWallet = function(url) {
|
|||||||
url = url || 'wc://';
|
url = url || 'wc://';
|
||||||
url = `https://metamask.app.link/wc?uri=${encodeURIComponent(url)}`;
|
url = `https://metamask.app.link/wc?uri=${encodeURIComponent(url)}`;
|
||||||
console.log('open native: ' + url);
|
console.log('open native: ' + url);
|
||||||
setTimeout(function() {
|
jsb.reflection.callStaticMethod(
|
||||||
jsb.reflection.callStaticMethod(
|
'UnityAppController',
|
||||||
'UnityAppController',
|
'toWallet:',
|
||||||
'toWallet:',
|
url
|
||||||
url
|
)
|
||||||
)
|
|
||||||
}, 6000)
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user