简介
通用链接比较麻烦,还要放配置文件到网站上面,简直让人深恶痛绝。Url Scheme
方式相对简单点。
添加URL Scheme

被打开后的处理
被打开之后,外部输入的url是可以接受到的。可以在AppDelegate.m
中的application:openURL:options:
方法中处理。这里只是展示一下url的内容
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
// 被外部浏览器打开,这里展示整个的url
NSString *test = url.absoluteString;
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"URL内容" message:test preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleDefault handler:nil]];
[self.window.rootViewController presentViewController:alert animated:YES completion:nil];
return YES;
}
测试1:Safari启动
在Safari浏览器中输入:haieruplus://host/path?param1=one
然后回车,就可以看到APP被打开:

测试2:在其他APP中启动
其他APP
只要用openURL
方法就可以唤起,只要保证scheme
是haieruplus://
就可以。
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"haieruplus://www.kjtpay.com?test=one"]];
问题1:可能会被支付宝禁止
写了一个scheme跳转,通过Safari浏览器,通过其他app,通过H5页面,都能够正常唤起APP。
但是,APP通过openURL拉起支付宝,支付宝再跳转H5页面,在H5页面中,想再唤起APP,就没有反应了。
网友评论