Skip to content

Instantly share code, notes, and snippets.

@zhangzhibin
Created July 16, 2021 08:14
Show Gist options
  • Save zhangzhibin/8ce1717d0d33cd475d81d86249fdf8ef to your computer and use it in GitHub Desktop.
Save zhangzhibin/8ce1717d0d33cd475d81d86249fdf8ef to your computer and use it in GitHub Desktop.
create shortcut in Facebook Instant Game, visit https://xmanyou.com for more.
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