浏览器判断是否安装某APP,如果安装则拉起,未安装则跳转下载页
in 心情分享心情DZ with 0 comment

浏览器判断是否安装某APP,如果安装则拉起,未安装则跳转下载页

in 心情分享心情DZ with 0 comment

timg.jpg

Android端

在AndroidManifest.xml的MAIN Activity下追加以下内容。(启动Activity时给予)

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="penhot" android:host="com.app" android:pathPrefix="/penhot"/>
</intent-filter>

iOS端

在info.plist文件中添加:

<key>CFBundleIdentifier</key>
  <string>com.mycompany.AppleScript.XXXX</string>
  <key>CFBundleURLTypes</key>
  <array>
    <dict>
      <key>CFBundleURLName</key>
      <string>penhot</string>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>penhot</string>
      </array>
    </dict>
  </array>

Android(安卓)设备:

if(isAndroid){  
     function android(){  
        window.location.href = "penhot://com.penhot.app"; /***打开app的协议,有安卓同事提供***/  
        window.setTimeout(function(){  
           window.location.href = "http://www.penhot.com/index.html"; /***打开app的协议,有安卓同事提供***/  
     },2000);  
};  

iOS(苹果)设备:

if(isiOS){  
      function ios(){  
        var ifr = document.createElement("iframe");  
        ifr.src = "penhot://com.penhot.ipa"; /***打开app的协议,有ios同事提供***/  
        ifr.style.display = "none";   
        document.body.appendChild(ifr);  
        window.setTimeout(function(){  
          document.body.removeChild(ifr);  
           window.location.href = "http://www.penhot.com/index.html"; /***下载app的地址***/  
        },2000)  
      };  
}  
Responses
');