跳转至应用市场所对应应用的详情介绍页,可用于对当前应用引导用户下载或升级,具体 code 实现可参考如下:
/*跳转至应用市场应用详情页*/
function pushAppStoreDetail(abilityContext?: common.UIAbilityContext) {
let bundleName: string = '当前应用的 bundleName'; // 例如: com.xxx.xxx 参考项目 app.json5 中配置
let uri: string = `store://appgallery.huawei.com/app/detail?id=${bundleName}`
let context = getContext() as common.UIAbilityContext
const wantInfo: Want = {
uri: uri
};
context.startAbility(wantInfo).then(() => {
console.log('[跳转至 App Store] - success')
}).catch((err: BusinessError) => {
console.error(`[跳转至 App Store] - Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
})
}
以上便是此次分享的全部内容,希望能对大家有所帮助!