基础库 1.41.0 开始支持本方法,这是一个异步方法。
在小游戏内调起关注小游戏的引导组件,用于引导用户关注小游戏。
前提条件 | 无 |
业务背景 | 无 |
使用限制 | 无 |
注意事项 | 展现策略仅在线上版、审核版有效,测试版、预览版不受限制。 |
相关教程 | 无 |
语法
tt.showFavoriteGuide(options)
参数说明
options 为 object 类型,属性如下:
属性名 | 类型 | 默认值 | 必填 | 说明 | 最低支持版本 |
---|
content | string | 一键添加到我的小程序 | 否 | 当 type == “tip” 时,可以配置文案,最多显示 12 个字符 | 1.41.0 |
position | string | bottom | 否 | 弹窗类型为 bar 时的位置参数,可以是 bottom(贴近底部)、overtab(悬于页面 tab 区域上方) | 1.41.0 |
type | string | | 是 | 组件类型:bar(底部弹窗)、tip(顶部气泡)、customize(自定义组件) | 1.41.0 |
success | function | | 否 | | 1.41.0 |
fail | function | | 否 | | 1.41.0 |
complete | function | | 否 | | 1.41.0 |
回调成功
object 类型,属性如下:
属性名 | 类型 | 说明 | 最低支持版本 |
---|
isFavorited | boolean | 返回是否收藏的信息,true:用户已收藏 ; false:用户未收藏 | 2.62.0 |
errMsg | string | | 1.41.0 |
回调失败
object 类型,属性如下:
属性名 | 类型 | 说明 | 最低支持版本 |
---|
errMsg | string | "showFavoriteGuide:fail" + 详细错误信息 | 1.41.0 |
错误码
errNo | errMsg | 说明 | 最低支持版本 |
---|
20000 | internal error | | 1.41.0 |
10301 | feature is not supported in app isLogin/sessionId | | 1.41.0 |
10401 | Internal error: common env error | | 1.41.0 |
21000 | favorites function offline | | 1.41.0 |
21000 | launch from feed not support favorites tip | | 1.41.0 |
20000 | unknown `type` | | 1.41.0 |
扫码体验
![]()
请使用字节宿主APP扫码
代码示例
开发者工具中预览
tt.showFavoriteGuide({
type: "customize",
success(res) {
console.log("isFavorited", res.isFavorited);
},
fail(res) {
console.log("自定义弹窗展示失败");
},
});
tt.showFavoriteGuide({
type: "bar",
content: "一键添加到我的小程序",
position: "bottom",
success(res) {
console.log("引导组件展示成功");
},
fail(res) {
console.log("引导组件展示失败");
},
});