美文网首页
URL Scheme

URL Scheme

作者: 搬砖的crystal | 来源:发表于2019-05-22 16:28 被阅读0次

    一、简介

    URL Scheme就是一个可以让app相互之间可以跳转的对外接口。通过给APP定义一个唯一的URL路径来从外部快速的打开这个指定的APP。

    URL Schemes有两个单词:

    • URL,我们都很清楚,http://www.apple.com 就是个 URL,我们也叫它链接或网址;
    • Schemes,表示的是一个 URL 中的一个位置——最初始的位置,即 ://之前的那段字符。比如 http://www.apple.com 这个网址的 Schemes 是 http。
      URL Schemes没有统一的编写规范。
      iOS9之后需要在info.plist设置白名单
      211BEA24-1CAC-46F2-8957-968FB295D4B2.png

    二、使用

    1.注册URL Scheme
    • 方法1:在 TARGETS -> Info -> URL Types 点击添加


      52E2F8E4-AF46-4DD3-9D01-F35E54643683.png
    • 方法2:在info.plist中添加 URL Types类型为 Array
    2.打开系统功能
    //iOS 11之后,只能跳转到设置首页或对应app的权限详情页
    //跳转到app对应的权限详情界面
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:^(BOOL success) {
            //成功回调
    }];
    //调用自带mail
     [[UIApplicationsharedApplication] openURL [NSURLURLWithString:@"mailto://邮箱"]];
     //调用电话
     [[UIApplication sharedApplication] openURL:[NSURLURLWithString:@"tel://电话"]];
     //调用SMS
    [[UIApplicationsharedApplication] openURL:[NSURL URLWithString:@"sms://号码"]];
     //调用自带浏览器safari
     [[UIApplicationsharedApplication] openURL:[NSURLURLWithString:@"http://www.baidu.com"]];
    //调用Remote
    [[UIApplicationsharedApplication] openURL:[NSURL URLWithString:@"remote://***"]]; 
    

    相关文章

      网友评论

          本文标题:URL Scheme

          本文链接:https://www.haomeiwen.com/subject/ldriaqtx.html