添加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;
}通过H5页面唤起
<a href="haieruplus://ygmx.app/openwith?name=zhangsan&age=26">启动APP</a>
通过其他APP启动(通过openURL即可)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"haieruplus://ygmx.app/openwith?name=zhangsan&age=26"]];

微信扫码查看本文
发表评论