store: // appgallery.huawei.com/app/detail?id=+bundleName
// 比如123456是实际的appid。前面拼接上大写的C store: // appgallery.huawei.com/app/detail?id=C123456
参考以下代码结构,排查传入uri等参数是否正确,跳转应用市场uri常见错误id前未加大写C。
import { Want } from '@kit.AbilityKit';
let wantInfo: Want = {
action: 'ohos.want.action.search',
entities: [ 'entity.system.browsable' ],
uri: 'store: // appgallery.huawei.com/app/detail?id=Cxxxxxxx',
type: 'text/plain',
}; 参考以下Demo正确实现链接跳转下载应用功能:
import Want from '@ohos.app.ability.Want';
import common from '@ohos.app.ability.common';
@Entry
@Component
struct Index {
build() {
Row() {
Column() {
Button('点击跳转到应用市场详情页面')
.margin({top: 50})
.onClick(()=>{
const want: Want = {
// 隐式指定action为ohos.want.action.appdetail
action: 'ohos.want.action.appdetail',
// bundleName为需要拉起写评论页的应用包名
uri: 'store://appgallery.huawei.com/app/detail?id=com.huawei.hmos.vmall'
};
const context = this.getUIContext().getHostContext() as common.UIAbilityContext;
context.startAbility(want).then(()=>{
// 拉起成功
}).catch(()=>{
// 拉起失败
});
})
}
.width('100%')
}
.height('100%')
}
}