MUI-判断苹果应用是否已安装qq和微信
/**
* 江节胜
* 判断本地是否安装客户端 如果还有问题就通过接口控制当前版本的显示隐藏
*/
var isInstalled = function(id) {
if(mui.os.android) {//未测试
var main = plus.android.runtimeMainActivity();
var packageManager = main.getPackageManager();
var PackageManager = plus.android.importClass(packageManager)
var packageName = {
"qq": "com.tencent.mobileqq",
"weixin": "com.tencent.mm",
"sinaweibo": "com.sina.weibo"
}
try {
return packageManager.getPackageInfo(packageName[id], PackageManager.GET_ACTIVITIES);
} catch(e) {
mui.toast(e)
}
} else {
switch(id) {
case "qq":
//com.tencent.mobileqq
var TencentOAuth = plus.ios.import("TencentOAuth");
return TencentOAuth.iphoneQQInstalled();
case "weixin":
if(plus.runtime.isApplicationExist({
pname: 'com.tencent.mm',
action: 'weixin://'
})) {
//console.log("微信应用已安装");
return true;
} else {
//console.log("微信应用未安装");
return false;
}
/*var WXApi = plus.ios.import("WXApi");//实测不生效
return WXApi.isWXAppInstalled()*/
/*case "sinaweibo": 返回 undefined
var SinaAPI = plus.ios.import("WeiboSDK");
return SinaAPI.isWeiboAppInstalled()*/
default:
break;
}
}
}
正文到此结束