# ks.addShortcut

更新时间:2024-11-14 19:28:12

添加小游戏快捷方式到手机桌面上,IOS不支持回调。

如果想要看用户是否从桌面快捷方式进来,可以调用ks.isLaunchFromShortcut (opens new window)接口

请求 object

字段名 类型 描述 values
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数
complete function 接口调用结束的回调函数(调用成功、失败都会执行)

回调成功

字段名 类型 描述 values
code int 1 表示成功
msg string "addShortcut:ok"

回调失败

字段名 类型 描述 values
code int 异常错误码
msg string "addShortcut:fail"

example

ks.addShortcut({  
  success() {  
    console.log("添加桌面成功");  
  },  
  fail(err) {  
    if (err.code === -10005) {  
        console.log("暂不支持该功能");  
    } else {  
        console.log("添加桌面失败", err.msg);  
    }  
  },  
});  
Copyright ©2025, All Rights Reserved