我也是看了几个大神的博客才总结出自己的笔记的,虽然有抄来之嫌,但是总觉得自己不写点,好像自己不认识,也不放心
function openApp(){
//var ua = window.navigator.userAgent.toLowerCase();
if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
var urlStr = "weixin://";
var UIApplication = plus.ios.import("UIApplication");
var NSURL = plus.ios.import('NSURL');
var demo = NSURL.URLWithString(urlStr);
var application = UIApplication.sharedApplication();
var a = application.openURL(demo);
if(!a){
var urlStr = "";//下载地址
var UIApplication = plus.ios.import("UIApplication");
var NSURL = plus.ios.import('NSURL');
var demo = NSURL.URLWithString(urlStr);
var application = UIApplication.sharedApplication();
application.openURL(demo)
}
plus.ios.deleteObject(demo);
plus.ios.deleteObject(application);
}else if (navigator.userAgent.match(/android/i)) {
try{
var Intent = plus.android.importClass("android.content.Intent");
var intent = new Intent(Intent.ACTION_VIEW);
var ComponentName = plus.android.importClass("android.content.ComponentName");
//var comp = new ComponentName("你的安卓APK的Package,在AndroidManifest.xml里面,比如yy.com.testandriodapp", "你的安卓APK启动控制器,比如yy.com.testandriodapp.MainActivity");
var comp = new ComponentName("vip.chinazt.ztuser", "vip.chinazt.ztuser.ui.LeadActivity");
intent.setComponent(comp);
var main = plus.android.runtimeMainActivity();
main.startActivity(intent);
}catch(e){
//console.log(e);
window.location.href='http://a.app.qq.com/o/simple.jsp?pkgname=vip.chinazt.ztuser';
return;
}
}
}