HarmonyOS 在H5中如何跳转到应用市场

非store协议,实测store协议在系统浏览器中跳转无效。

HarmonyOS
2024-09-06 09:42:49
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
zbw_apple

【store协议】h5跳转拉起应用市场APP并跳转到应用详情页demo:

【AppJump.ets】

import web_webview from '@ohos.web.webview'; 
import { common, Want } from '@kit.AbilityKit'; 
 
class NaviAppStore { 
  constructor() { 
  } 
 
  jumpAgcDetailPage() { 
    const want: Want = { 
      uri: `store://appgallery.huawei.com/app/detail?id=xxx` //跳转拉起应用市场  
      // uri: `store://appgallery.huawei.com/`   //跳转拉起应用市场APP首页 
    } 
    const context = getContext(this) as common.UIAbilityContext; 
    context.startAbility(want).then(() => { 
      console.log('jumpAgcDetailPage 拉起成功 '); 
    }).catch(() => { 
      console.log('jumpAgcDetailPage 拉起失败'); 
    }) 
  } 
} 
 
@Entry 
@Component 
struct WebPage { 
  controller: web_webview.WebviewController = new web_webview.WebviewController() 
  @State naviApp:NaviAppStore = new NaviAppStore() 
 
  build() { 
    Row() { 
      Column() { 
        Web({ src: $rawfile("go_to_agc_unipay.html"), controller: this.controller }) 
          .javaScriptProxy({ 
            object: this.naviApp, 
            name: "naviApp", 
            methodList: ["jumpAgcDetailPage"], 
            controller: this.controller 
          }) 
      } 
      .width('100%') 
    } 
    .height('100%') 
  } 
}

【go_to_agc_unipay.html】

<!-- index.html --> 
  <!DOCTYPE html> 
  <html> 
  <body> 
  <button type="button" onclick="callArkTS()">Click Me!</button> 
  <p id="demo"></p> 
  <script> 
  function callArkTS() { 
    let str = naviApp.jumpAgcDetailPage(); 
  } 
  </script> 
  </body> 
  </html>
分享
微博
QQ
微信
回复
2024-09-06 15:27:29
相关问题
怎样才能跳转到应用市场界面?
516浏览 • 2回复 待解决
如何跳转到应用市场app下载页面?
6918浏览 • 1回复 待解决
HarmonyOS web组件加载h5h5拉起摄像头
132浏览 • 1回复 待解决
如何HarmonyOS调试h5页面
560浏览 • 1回复 待解决
Webwebview和H5交互
744浏览 • 1回复 待解决
HarmonyOS web与H5交互
174浏览 • 1回复 待解决
HarmonyOS H5应用侧数据交互的Demo
110浏览 • 1回复 待解决
HarmonyOS web原生和H5如何交互?
148浏览 • 1回复 待解决
HarmonyOS webview h5的localstorage
101浏览 • 1回复 待解决
如何在webview中使用H5的alert
823浏览 • 1回复 待解决
HarmonyOS 折叠屏H5适配问题
84浏览 • 1回复 待解决
HarmonyOS H5的JS端调用应用端的新问题
157浏览 • 0回复 待解决
H5通过url scheme拉起对应应用
193浏览 • 1回复 待解决
如何实现H5自定义事件
1956浏览 • 1回复 待解决
h5如何在鸿蒙设备进行调试
889浏览 • 1回复 待解决
webview加载Vue h5失败
17324浏览 • 5回复 待解决
HarmonyOS应用升级跳转应用市场推荐
107浏览 • 1回复 待解决
HarmonyOS h5页面缩放问题
134浏览 • 0回复 待解决