HarmonyOS 跳转到华为应用市场?

HarmonyOS应用中怎么在自己的APP中拉起HarmonyOS应用市场APP,让用户去更新APP?

阅读 594
1 个回答

参考下文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/store-update-V5

也可以通过appId拉起应用市场指定应用界面:

import Want from '@ohos.app.ability.Want';
import common from '@ohos.app.ability.common';

@Entry
@Component
struct Index {
  @State appId: string = 'xxxx';
  controller: TextInputController = new TextInputController();

  build() {
    Row() {
      Column() {
        TextInput({ text: this.appId, placeholder: '请输入应用的appId', controller: this.controller })
          .width('90%')
          .onChange((value: string) => {
            this.appId = value
          })
        Button('点击跳转到HarmonyOS版应用市场详情页面')
          .margin({ top: 50 })
          .onClick(() => {
            const want: Want = {
              uri: store://appgallery.huawei.com/app/detail?id=${this.appId}
            };
            const context = getContext(this) as common.UIAbilityContext;
            context.startAbility(want).then(() => {
              //拉起成功
            }).catch(() => {
              // 拉起失败
            });
          })
      }
      .width('100%')
    }
    .height('100%')
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进