【代码】H5页面实现唤起IOSAPP并传递参数

2020-08-10 14:23:50  阅读 3059 次 评论 0 条

添加URL Scheme

20200810142244.png


被打开之后,外部输入的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"]];



微信扫码查看本文
本文地址:https://www.yangguangdream.com/?id=2092
版权声明:本文为原创文章,版权归 编辑君 所有,欢迎分享本文,转载请保留出处!

发表评论


表情

还没有留言,还不快点抢沙发?