美文网首页
iOS利用URL Scheme打开第三方app

iOS利用URL Scheme打开第三方app

作者: 倾倒的吞天壶 | 来源:发表于2018-07-30 15:47 被阅读249次
第三方app端
image.png
demo app端
  1. 跳转代码
        let urlString = "weixin://"
        let url = URL(string: urlString)
        if UIApplication.shared.canOpenURL(url!) {
            UIApplication.shared.open(url!)
        }else{
            let appString = "https://www.apple.com/itunes/"
            let appUrl = URL(string: appString)
            UIApplication.shared.open(appUrl!)
        }
  1. 添加属性
    info.plist源码视图下添加:
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <!-- weixin URL Scheme 白名单-->
        <string>weixin</string>
    </array>

相关文章

网友评论

      本文标题:iOS利用URL Scheme打开第三方app

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