1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/**
* 180823 江节胜 处理
* 判断本地是否安装客户端 如果还有问题就通过接口控制当前版本的显示隐藏
*/
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' ,
})) {
//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 ;
}
}
}
|
有任何疑问或技术合作都可联系我
微信:yanfahezuo 【推荐】
QQ:596957738