Created
July 16, 2021 08:14
-
-
Save zhangzhibin/8ce1717d0d33cd475d81d86249fdf8ef to your computer and use it in GitHub Desktop.
create shortcut in Facebook Instant Game, visit https://xmanyou.com for more.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tryCreateShortcutAsync(){ | |
if(!FBInstant){ | |
console.info("FBInstant Not Available"); | |
return; | |
} | |
console.info("Try Create shortcut"); | |
FBInstant.canCreateShortcutAsync() | |
.then(function(canCreateShortcut) { | |
console.info("canShortcutAsync: ", canCreateShortcut); | |
// 如果可以创建 | |
if (canCreateShortcut) { | |
// 2. 尝试创建快捷方式 | |
FBInstant.createShortcutAsync() | |
.then(function() { | |
// 创建成功 | |
console.info("Call createShortcutAsync done"); | |
}) | |
.catch(function(e) { | |
// 创建失败或者取消 | |
console.warn("Call createShortcutAsync Failed: ", e); | |
}); | |
} | |
// 不能创建 | |
}) | |
.catch(function(e){ | |
console.info("canShortcutAsync Failed: ", e); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment