url scheme

Tags
htmlwebapiios
Created
Feb 19, 2016 7:29 AM

mac scheme list:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump URLSchemeBinding

不同系统不同浏览器对 url 格式有不同的限制,所以还需要转变一下。

安卓原生浏览器,url地址需要变成 javascript:window.location.href='weixin://dl/favorites';

Chrome 浏览器可以直接用 weixin://dl/favorites

QQ 浏览器要用到 data url data:text/html,<html><script>window.location.href='weixin://dl/favorites';</script></html>

/android/i.test(a) ? a.match(/MQQBrowser|UCBrowser|360Browser|Firefox|baidubrowse|SogouMobileBrowser|LieBaoFast|XiaoMi\/MiuiBrowser|opr/i) ? b = "iframe" : a.match(/Chrome/i) && window.chrome ? b = "open" : b = "iframe" : a.match(/360Browser|QHBrowser|MQQBrowser/i) ? b = "open" : b = "iframe";

// 有些浏览器用open窗口打开url scheme,有些则用 iframe 打开,(via:sina微博的分享页脚本)

// 检测是否成功打开 : open 方法的可以检测打开的 window 的 location.href 值,为表示打开成功(推荐);不成功跳转到 webapp

// iframe 打开 app 的(IOS9+不能)可以立即监听页面 visibilitychange 事件(移动端切换app不会触发onblur)和 blur(pc相反)

// IOS9 推出了Universal links,根据 apple-app-site-association 文件会在指定链接自动尝试调用app打开

1. It must be sent with the header ‘application/pkcs7-mime’

2. It must be sent from the endpoint youdomain.com/apple-app-site-association

3. It must return a 200 http code.

4.  must use SSL

// IOS 9已经停止支持URL scheme

google index app(搜索结果中可以直接调用app):<link rel="alternate" href="imdb://title/tt0117500/" />

web 可以注册协议 web+,使用指定网站打开该协议

任何协议都遵循 URL 的规范,比如编码

ios 下有复杂的 url scheme 规范:x-callback-url

http://sspai.com/31500

IOS 中基于 URL 规范的简单 url scheme 可以在 app 文件夹内info.plist文件的 CFBundleURLSchemes 中看到

SuperMade with Super