ios下,分享页面在QQ内置浏览器打开,window.location=“ios人员给的某个协议”,打不开app,可是安卓能够打开,求大佬翻牌解惑
var browser = {
versions: function () {
var u = navigator.userAgent,
app = navigator.appVersion;
return {
trident: u.indexOf('Trident') > -1, /*IE内核*/
presto: u.indexOf('Presto') > -1, /*opera内核*/
webKit: u.indexOf('AppleWebKit') > -1, /*苹果、谷歌内核*/
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, /*火狐内核*/
mobile: !!u.match(/AppleWebKit.*Mobile.*/), /*是否为移动终端*/
ios: !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/), /*ios终端*/
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, /*android终端或者uc浏览器*/
iPhone: u.indexOf('iPhone') > -1, /*是否为iPhone或者QQHD浏览器*/
iPad: u.indexOf('iPad') > -1, /*是否iPad*/
webApp: u.indexOf('Safari') == -1, /*是否web应该程序,没有头部与底部*/
souyue: u.indexOf('souyue') > -1,
superapp: u.indexOf('superapp') > -1,
weixin: u.toLowerCase().indexOf('micromessenger') > -1,
Safari: u.indexOf('Safari') > -1
};
}(),
language: (navigator.browserLanguage || navigator.language).toLowerCase()
};
document.querySelector(".cyj-download-btn").onclick = function () {
document.querySelector(".show-dialog").style.display = "block";
setTimeout(function () {
document.querySelector(".show-dialog").style.display = "none";
},1000);
if (browser.versions.ios) {
window.location.href = "打开该App的连接://openApp";
setTimeout(function () {
window.location.href = "该App的连接地址;
window.location.href = "该App的连接地址";
}, 2000)
} else if (browser.versions.android) {
window.location.href = "打开该App的连接://openApp";
setTimeout(function () {
window.location.href = "该App的连接地址";
}, 2000)
}
};
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>com.test.jay</string>
<key>CFBundleURLSchemes</key>
<array>
<string>test</string>
</array>
</dict>
</array>
假设在ios客户端配置的是上面URLSchemes,那么你可以直接在safiri使用test://直接打开这个原生应用;
不能跳转的原因
可能是ios应用的URLSchemes配置有问题
你直接跳转到appstore说明前面的转到应用的判断条件不满足,你可以检查这个条件判断。
iOS中通过QQ唤醒应用是需要通过scheme拉起的,推荐你使用openinstall免费提供的一键拉起功能,大致原理就是在网页和客户端同时配置scheme然后相互匹配进行拉起
拉起后还可根据网页参数跳转对应页面,配置过程操作简单。