38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
if (window.JavascriptJavaBridge) {
|
|
console.log('regist android jsb.reflection')
|
|
jsb.reflection = new JavascriptJavaBridge();
|
|
} else if (window.JavaScriptObjCBridge) {
|
|
jsb.reflection = new JavaScriptObjCBridge();
|
|
}
|
|
window.jumpToWallet = function(url) {
|
|
url = url || 'wc://';
|
|
if (window.JavascriptJavaBridge) {
|
|
url = 'metamask://wc?uri=' + url;
|
|
} else {
|
|
url = `https://metamask.app.link/wc?uri=${encodeURIComponent(url)}`;
|
|
}
|
|
console.log('open native: ' + url);
|
|
jsb.toWallet(url);
|
|
}
|
|
|
|
window.toRelayPage = function(url) {
|
|
// https://metamask.app.link/dapp/www.sample.com/page.html
|
|
// okx://wallet/dapp/details?dappUrl=https://www.sample.com/page.html
|
|
let okxUrl = `okx://wallet/dapp/details?dappUrl=${url}`;
|
|
//let okxUrl = `https://metamask.app.link/dapp/${url.replace('https://', '')}`;
|
|
jsb.toWallet(okxUrl);
|
|
}
|
|
function nativeCallBack(...args) {
|
|
console.log(`jniCallback: ${args[0]}`);
|
|
jc.wallet.nativeSvr.handleNativeCallback(...args);
|
|
}
|
|
|
|
function onGamePause() {
|
|
console.log('game pause');
|
|
}
|
|
function onGameResume() {
|
|
console.log('game resume');
|
|
jc.wallet.relaySvr.checkResult();
|
|
}
|
|
|