目录

通过链接跳转到应用市场提示不支持在当前设备安装

问题现象

点击链接跳转至应用市场后,提示“不支持在当前设备安装”,无法完成应用的下载和安装操作。

背景知识

问题定位

参考以下代码结构,排查传入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',
};

分析结论

uri参数错误,bundleName传参错误或者在使用旧链接方式的时候id前未加大写C。

修改建议

参考以下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%')
  }
}