H5+ app Vue calls third-party applications, if no installation jumps to app market details

1. Call a third-party application to determine if it is installed plus.runtime.isApplicationExist() ...
1. Call a third-party application to determine if it is installed
2. Determine if the current device is Android or ios
3. Call third-party applications
4. If you don't have the app installed, open the local app store and the Apple system opens the APP store directly. Here's an example of opening the Golden Map
5. Call the mobile app market, if Android has only one app market open directly, if there are more than one, it will pop up a window to choose from and ios will open the APP Store directly
6. Call a third-party program to navigate, Android will get all the navigation applications installed on the device, pop-up window selection box, if only one opens directly, ios opens the system navigation application (Golden)

1. Call a third-party application to determine if it is installed

plus.runtime.isApplicationExist()

pname is the Android application package name, action is the URL Scheme when ios is called, returns boolean

2. Determine if the current device is Android or ios

plus.os.name === "Android" plus.os.name === "iOS"

3. Call third-party applications

Android plus.runtime.launchApplication( , function ( e ) { _this.$toast( "Open system default browser failed: " + e.message ); } ); //Apple plus.runtime.launchApplication( , function ( e ) { _this.$toast( "Open system default browser failed: " + e.message ); });

4. If you don't have the app installed, open the local app store and the Apple system opens the APP store directly. Here's an example of opening the Golden Map

_this.$confirm('You haven't installed the app yet,Whether to go to the App Store to download').then(res=>{ if(res){ console.log('_this.pname:::::'+_this.pname); if ( plus.os.name === "Android" ) { _this.getDeviceAppStore();// Get App Stores setTimeout(()=>{ if(_this.pname === ''));return;} plus.runtime.openURL( "market://details?id=com.autonavi.minimap", function (e) { _this.$toast('Failed to open') },_this.pname); },100) } else if ( plus.os.name === "iOS" ) { plus.runtime.openURL('https://apps.apple.com/cn/app/%E9%AB%98%E5%BE%B7%E5%9C%B0%E5%9B%BE-%E7%B2%BE%E5%87%86%E5%9C%B0%E5%9B%BE-%E5%AF%BC%E8%88%AA%E5%87%BA%E8%A1%8C%E5%BF%85%E5%A4%87/id461703208'); } } }) getDeviceAppStore(){// Get the device's app store package name, for Android let _this = this; this.plusReady(()=>{ if ( plus.os.name === "iOS" )return; // Get the current device manufacturer let vender = plus.device.vendor; console.log(vender); // Obtain the package name of the app store from the device manufacturer, or give the user a list of third-party app markets if no device manufacturer is available switch (vender){ case 'HUAWEI': case 'HONOR': _this.pname = 'com.huawei.appmarket';// Huawei, Glory break; case 'ONEPLUS': case 'OPPO': _this.pname = 'com.oppo.market';// OPPO, One Plus break; case 'VIVO': _this.pname = 'com.bbk.appstore';// vivo break; case 'MEIZU': _this.pname = 'com.meizu.mstore';// Meizu break; case 'XIAOMI': _this.pname = 'com.xiaomi.market';// millet break; case 'LENOVO': _this.pname = 'com.lenovo.leos.appstore';// association break; case 'ZTE': _this.pname = 'zte.com.market';// ZTENDING break; case 'XIAOLAJIAO': _this.pname = 'com.zhuoyi.market';// ZOYI break; case '360': _this.pname = 'com.qihoo.appstore';// 360 Qihu break; case 'NUBIA': _this.pname = 'com.nubia.neostore';// Nubian break; case 'MEITU': _this.pname = 'com.android.mobile.appstore';// Meitu break; case 'SONY': _this.pname = 'com.android.vending';// Sony break; case 'GOOGLE': _this.pname = 'com.android.vending';//Google break; // case 'HTC': // case 'ZUK': default: _this.pname = ''; break; } console.log(_this.pname) }); },

In summary, when we click on the Open Golden Map button, we will first determine if it is installed or not, then what system is the current device, if . If you don't have

5. Call the mobile app market, if Android has only one app market open directly, if there are more than one, it will pop up a window to choose from and ios will open the APP Store directly

_this.plusReady(()=>{ if (plus.os.name === "iOS") { plus.runtime.openURL('itms-apps://itunes.apple.com'); } else if (plus.os.name === "Android") { let Uri = plus.android.importClass("android.net.Uri"); let uri = Uri.parse("market://details?id=" + 'com.tencent.mm' ); let Intent = plus.android.importClass('android.content.Intent'); let intent = new Intent(Intent.ACTION_VIEW, uri); let main = plus.android.runtimeMainActivity(); main.startActivity(intent); } });

The code above takes the example of opening WeChat and replaces it with the application you want to open, which is uploaded in https://ask.dcloud.net.cn/article/114 This is what the great gods are about Native.js Summary of some applications in Android and ios

6. Call a third-party program to navigate, Android will get all the navigation applications installed on the device, pop-up window selection box, if only one opens directly, ios opens the system navigation application (Golden)

_this.plusReady(()=>{ // Setting coordinate points of target position and starting position let dst = new plus.maps.Point(116.39131928,39.90793074); // Tiananmen let src = new plus.maps.Point(116.335,39.966); // Great Bell Temple // Call System Map Display plus.maps.openSysMap( dst, "Tiananmen", src ); });

15 June 2020, 21:47 | Views: 9836

Add new comment

For adding a comment, please log in
or create account

0 comments