iOS学习iOS 开发每天分享优质文章征服iOS

Deep Linking

2017-02-08  本文已影响56人  osbornZ

Deep linking 是指 mobile app 在 handle 特定URL的时候可以直接跳转到对应的内容页或触发特定逻辑,而不仅仅是启动 app。

驱动力

URL Scheme

iOS SDK支持,Application与自定义的URL Scheme绑定,通过在浏览器或者其他应用中启动这个App;

To enable deep linking, go to the Info tab in the Xcode project. In the URL Types section, click on the + button, and then add an identifier and a URL scheme< appID://  be sure to open the scheme in safari >

在*-Info.plist中添加一行选择URL types;添加自定义的identifier和URL scheme,一般推荐使用 com.x.x 和 appID://; scheme 不用加://

外部打开App, 需要在自己URL Types中增加URL Scheme ;
而我们App内需要打开别的App, 则要添加 LSApplicationQueriesSchemes(白名单)

9.0 以下系统处理逻辑
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;
外部链接接口方式跳转进入App处理 >= 9.0
- (BOOL)application:(UIApplication *)app openURL:(NSURL )url options:(NSDictionary<NSString, id> *)options;

协议解析
The format of the url is as follows: [scheme]://[host]/[path]
通过sourceApplication判断application,然后通过scheme判断自定义scheme,最后通过不同的协议头【path】进行对应的处理;

参考

Custom URL Schemes

Deep Linking in iOS

延迟深度链接

上一篇 下一篇

猜你喜欢

热点阅读