现在微信不屏蔽通用链接,QQ屏蔽了,只给他们自己旗下的qq音乐等产品可以通过QQ直接跳
https://www.jianshu.com/p/c2ca5b5f391f
iOS微信屏蔽通用链接 : https://www.jianshu.com/p/bf529236019b
https://shoujiduoduo.com/ios/aa.html
而且经过验证,发现网页的域名和点击打开按钮的跳转链接域名不能一样,看上面这个,(打开按钮的跳转域名是www.shoujiduoduo.com)如果
NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://shoujiduoduo.com/ios/aa.html"]
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:60.0];
[self.webView loadRequest:request];
这里写的是"shoujiduoduo.com",没有加www,这样可以,但是滑稽的是,如果写成
NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.shoujiduoduo.com/ios/aa.html"]
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:60.0];
[self.webView loadRequest:request];
,这里多了www,那么和跳转按钮的域名一样了,就不可以实现universal link了
html:
<!DOCTYPE html">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0">
<body bgcolor = "#FFEEDD">
<input type="text" id="acti">
<p>下载页面<a href="javascript:;" onclick="open_iOS_App()">ios 点击链接</a></p>
</body>
<a href="" id="aaa"></a>
<script type="text/javascript">
var timeout;
function open_iOS_App() {
if (isWeiXin()) {
open_App();
}else{
open_App();
timeout = setTimeout('open_itunes()', 3000);
};
}
function open_App() {
var ver = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
ver = parseInt(ver[1], 10);
if(ver<9)
{
if (isWeiXin()) {
open_weixin_App();
}else{
open_itunes();
}
} else{
var activity = document.getElementById("acti").value;
document.getElementById("aaa").href = "https://www.shoujiduoduo.com?params="+ encodeURI(activity);
// alert(document.getElementById("aaa").href);
// alert(activity);
document.getElementById("aaa").click();
}
}
function open_itunes() {/* 打开app store */
window.location="http://itunes.apple.com/cn/app/id801599025";
}
function open_weixin_App() {/* 打开腾讯应用宝 间接跳转 */
var acti = document.getElementById("acti").value;
window.location="http://a.app.qq.com/o/simple.jsp?pkgname=com.xxxx.xxxxx&activity=" + acti;
}
/*
判断是否是微信浏览器
*/
function isWeiXin(){
var ua = window.navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i) == 'micromessenger'){
return true;
}else{
return false;
}
}
function linktoApp() {
var queryStr = decodeURI(window.location.search.substr(1));
var ua = navigator.userAgent.toLowerCase();
if (queryStr.indexOf("}") >= 0 && queryStr.indexOf("{") >= 0) {
var activity = queryStr.substring(queryStr.indexOf("{"), queryStr.lastIndexOf("}") + 1);
document.getElementById("acti").value = activity;
if (/iphone|ipad|ipod/.test(ua)) {
// IOS
} else if (/android/.test(ua)) {
// Android
} else {
// 其他浏览器
window.location="http://a.app.qq.com/o/simple.jsp?pkgname=com.xxxxxxx.xxxxxxxx";
}
} else {
document.getElementById("acti").value = "参数格式错误";
}
}
// 用js实现在加载完成一个页面后自动执行一个方法
/*用window.onload调用myfun()*/
window.onload=linktoApp;//不要括号
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0">
<body bgcolor = "#FFEEDD">
<input type="text" id="acti">
<!--Safriy 和 App内打开都行-->
<p>下载页面<a href="javascript:;" onclick="open_iOS_App()">ios universalLink点击链接</a></p>
<!--Safriy能打开 || App内打不开-->
<p>下载页面<a href="javascript:;" onclick="open_iOS_App1()">ios scheme点击链接</a></p>
<p>下载页面<a href="javascript:;" onclick="open_iOS_App2()">ios universalLink点击链接2</a></p>
<p>下载页面<a href="javascript:;" onclick="open_iOS_App3()">ios scheme点击链接2</a></p>
<!-- -->
<!-- <div>-->
<!-- <div class="cenBox">-->
<!-- <div>-->
<!-- <!--<a href="JavaScript:createMusicAlbum();" class="share"><em><img src="http://cdnwebuc.shoujiduoduo.com/ringres/web/share/mobile/photo.png" width="30px"></em><span>做相册</span></a>-->-->
<!-- <a href="JavaScript:OnDown('lingshengduoduo');" class="downLoad"><em> width="30px"></em><span>下载铃声多多<!-- <i>让你的手机更个性</i> --></span></a></div>-->
<!-- </div>-->
<!-- </div>-->
</body>
<a href="" id="aaa"></a>
<script type="text/javascript">
<!-- function OnDown(product_id, needconfirm) {-->
<!-- -->
<!-- -->
<!-- openApp44();-->
<!---->
<!-- }-->
<!---->
<!--function openApp44() {-->
<!-- -->
<!-- window.location.href = "https://www.baidu.com";-->
<!-- -->
<!-- }-->
<!---->
var timeout;
function open_iOS_App() {
if (isWeiXin()) {
open_App();
}else{
open_App();
timeout = setTimeout('open_itunes()', 3000);
};
}
function open_iOS_App1() {
open_App1();
}
function open_iOS_App2() {
open_App2();
}
function open_iOS_App3() {
open_App3();
}
function open_App() {
var ver = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
ver = parseInt(ver[1], 10);
if(ver<9)
{
if (isWeiXin()) {
open_weixin_App();
}else{
open_itunes();
}
} else{
var activity = document.getElementById("acti").value;
<!--document.getElementById("aaa").href = "https://www.shoujiduoduo.com/ringv1/ioshelp/help1/help3.php?params="+ encodeURI(activity);-->
<!--document.getElementById("aaa").href = "https://m.music.163.com/m/applink/?params="+ encodeURI(activity);-->
<!--document.getElementById("aaa").href = "https://www.shoujiduoduo.com/ringv1/ioshelp/help1/help3.php?params="+ encodeURI(activity);-->
document.getElementById("aaa").href = "https://www.shoujiduoduo.com";
document.getElementById("aaa").click();
}
}
function open_App1() {
var ver = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
ver = parseInt(ver[1], 10);
var activity = document.getElementById("acti").value;
document.getElementById("aaa").href = "RingToneDD://";
document.getElementById("aaa").click();
}
function open_App2() {
var ver = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
ver = parseInt(ver[1], 10);
window.location.href = "https://www.shoujiduoduo.com";
}
function open_App3() {
var ver = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
ver = parseInt(ver[1], 10);
window.location.href = "RingToneDD://";
}
function open_itunes() {/* 打开app store */
<!--window.location="http://itunes.apple.com/cn/app/id801599025";-->
}
function open_weixin_App() {/* 打开腾讯应用宝 间接跳转 */
var acti = document.getElementById("acti").value;
window.location="http://a.app.qq.com/o/simple.jsp?pkgname=com.xxxx.xxxxx&activity=" + acti;
}
/*
判断是否是微信浏览器
*/
function isWeiXin(){
var ua = window.navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i) == 'micromessenger'){
return true;
}else{
return false;
}
}
function linktoApp() {
var queryStr = decodeURI(window.location.search.substr(1));
var ua = navigator.userAgent.toLowerCase();
if (queryStr.indexOf("}") >= 0 && queryStr.indexOf("{") >= 0) {
var activity = queryStr.substring(queryStr.indexOf("{"), queryStr.lastIndexOf("}") + 1);
document.getElementById("acti").value = activity;
if (/iphone|ipad|ipod/.test(ua)) {
// IOS
} else if (/android/.test(ua)) {
// Android
} else {
// 其他浏览器
window.location="http://a.app.qq.com/o/simple.jsp?pkgname=com.xxxxxxx.xxxxxxxx";
}
} else {
document.getElementById("acti").value = "参数格式错误";
}
}
// 用js实现在加载完成一个页面后自动执行一个方法
/*用window.onload调用myfun()*/
window.onload=linktoApp;//不要括号
</script>
</head>
<body>
</body>
</html>
网友评论