iOS开发学习笔记(OC语言)——调起APP(URL Scheme)

通过URL Scheme调起APP

  1. 在 Info.plist 中添加url scheme白名单
    <key>LSApplicationQueriesSchemes</key>
     <array>
        <!-- 微信 URL Scheme 白名单-->
        <string>wechat</string>
        <string>weixin</string>

        <!-- 新浪微博 URL Scheme 白名单-->
        <string>sinaweibohd</string>
        <string>sinaweibo</string>
        <string>sinaweibosso</string>
        <string>weibosdk</string>
        <string>weibosdk2.5</string>

        <!-- QQ、Qzone URL Scheme 白名单-->
        <string>mqqapi</string>
        <string>mqq</string>
        <string>mqqOpensdkSSoLogin</string>
        <string>mqqconnect</string>
        <string>mqqopensdkdataline</string>
        <string>mqqopensdkgrouptribeshare</string>
        <string>mqqopensdkfriend</string>
        <string>mqqopensdkapi</string>
        <string>mqqopensdkapiV2</string>
        <string>mqqopensdkapiV3</string>
        <string>mqzoneopensdk</string>
        <string>wtloginmqq</string>
        <string>wtloginmqq2</string>
        <string>mqqwpa</string>
        <string>mqzone</string>
        <string>mqzonev2</string>
        <string>mqzoneshare</string>
        <string>wtloginqzone</string>
        <string>mqzonewx</string>
        <string>mqzoneopensdkapiV2</string>
        <string>mqzoneopensdkapi19</string>
        <string>mqzoneopensdkapi</string>
        <string>mqzoneopensdk</string>

        <!-- 支付宝  URL Scheme 白名单-->
        <string>alipay</string>
        <string>alipayshare</string>

    </array>
  1. 判断是否能调起,否则安装
NSURL *urlScheme = [NSURL URLWithString:@"weixin://"];
if (![[UIApplication sharedApplication]canOpenURL:urlScheme]) {
    urlScheme = [NSURL URLWithString:@"itms-apps://itunes.apple.com/app/apple-store/id414478124"];
    NSLog(@"no weixin");
}
[[UIApplication sharedApplication]openURL:urlScheme options:nil completionHandler:^(BOOL success) {
    NSLog(@"success:%s", success ? "yes": "no");
}];

APP添加url scheme支持

posted @ 2022-03-01 09:09  观海云不远  阅读(448)  评论(0编辑  收藏  举报