写点什么

【HarmonyOS NEXT】鸿蒙跳转华为应用市场目标 APP 下载页

作者:GeorgeGcs
  • 2025-03-24
    上海
  • 本文字数:1080 字

    阅读完需:约 4 分钟

【HarmonyOS NEXT】鸿蒙跳转华为应用市场目标APP下载页

【HarmonyOS NEXT】鸿蒙跳转华为应用市场目标 APP 下载页

一、问题背景:

如今,大家都离不开各种手机应用。随着鸿蒙系统用户越来越多,大家都希望能在鸿蒙设备上快速找到想用的 APP。华为应用市场里有海量的 APP,但之前从鸿蒙设备进入应用市场找特定 APP 的过程有点繁琐。


从开发角度来说,打通鸿蒙设备到华为应用市场目标 APP 下载页的直接跳转,能优化整个开发链路。从产品需求出发,这能提升应用分发的效率,助力产品推广。


站在用户体验方面,这么做能大大节省用户找 APP 的时间,让大家更快下载想用的应用,极大地提升用户使用鸿蒙设备获取应用的体验。所以,实现这个跳转功能十分必要。

二、解决方案:

源码示例如下,以跳转到华为应用市场的 wx 界面举例:


跳转目标 app 的下载页,需要知道其包名即可。



点击跳转按钮后的效果:



import Want from '@ohos.app.ability.Want';import common from '@ohos.app.ability.common';import { BusinessError } from '@kit.BasicServicesKit';
@Entry@Componentstruct AGCStorePage { private TAG: string = "AGCStorePage";
// 以wx举例: @State mAppId: string = 'com.tencent.wechat'; controller: TextInputController = new TextInputController();
build() { Row() { Column() { TextInput({ text: this.appId, placeholder: '请输入应用的appId', controller: this.controller }) .width('90%') .onChange((value: string) => { this.mAppId = value })
Button('点击跳转到鸿蒙版应用市场详情页面') .margin({top: 50}) .onClick(()=>{ const want: Want = { uri: "store://appgallery.huawei.com/app/detail?id=" + this.mAppId }; const context = getContext(this) as common.UIAbilityContext; context.startAbility(want).then(()=>{ //拉起成功 console.log(this.TAG, "跳转成功!"); }).catch((err: BusinessError)=>{ // 拉起失败 console.log(this.TAG, "跳转失败!" + JSON.stringify(err)); }); }) } .width('100%') } .height('100%') }}
复制代码


注意:拼接分享的应用下载页链接为(以 wx 举例,替换 id 即可跳转到目标 app): https://appgallery.huawei.com/app/detail?id=com.tencent.wechat


在鸿蒙设备上加载该链接,为自动跳转到应用市场 app 下载页。若不是鸿蒙设备,会提示:



发布于: 2025-03-24阅读数: 3
用户头像

GeorgeGcs

关注

路漫漫其修远兮,吾将上下而求索。 2024-12-24 加入

历经腾讯,宝马,研究所,金融。 待过私企,外企,央企。 深耕大应用开发领域十年。 OpenHarmony,HarmonyOS,Flutter,H5,Android,IOS。 目前任职鸿蒙应用架构师。 HarmonyOS官方认证创作先锋

评论

发布
暂无评论
【HarmonyOS NEXT】鸿蒙跳转华为应用市场目标APP下载页_鸿蒙_GeorgeGcs_InfoQ写作社区