### [uniapp直接跳转应用商店](https://pmself.com/article/1926) **Published:** 2023-04-20T09:24:08 **Author:** pmself **Excerpt:** 参考一: // 跳转应用商店export const jumpToAppMarket = (code) => … 参考一: // 跳转应用商店 export const jumpToAppMarket = (code) => { // 可以根據文檔換成其他商店 https://www.jianshu.com/p/b544810beac3 const googlePlay = “com.android.vending”; ``` if (plus.os.name == "Android") { var Uri = plus.android.importClass("android.net.Uri"); var Intent = plus.android.importClass('android.content.Intent'); var main = plus.android.runtimeMainActivity(); var uri = Uri.parse("market://details?id=" + 包名); var intent = new Intent(Intent.ACTION_VIEW, uri); // 选择进入商店 intent.setPackage(googlePlay); intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK; // 没有该商店应用 if (intent.resolveActivity(main.getPackageManager()) !== null) { main.startActivity(intent); } else { // 跳转浏览器 let uri = Uri.parse("https://play.google.com/store/apps/details?id=" + 包名); let intent = new Intent(Intent.ACTION_VIEW, uri); intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK; intent.setPackage('com.android.browser'); main.startActivity(intent); } } else { plus.runtime.openURL('itms-apps://itunes.apple.com/cn/app/id{appid}?mt=8'); } ``` 参考二:安卓是指定包名跳转,iOS需要指定id ``` if (plus.os.name == "Android") { // 跳转安卓应用市场 let appurl = "market://details?id=com.tencent.mm" //这个是通用应用市场,如果想指定某个应用商店,需要单独查这个应用商店的包名或scheme及参数 plus.runtime.openURL(appurl) } else { // 跳转AppStore let appleId = 纯数字id plus.runtime.launchApplication({ action: `itms-apps://itunes.apple.com/cn/app/id${appleId}`, }) } ``` **Tags:** 应用商店 **Categories:** Uniapp ---