启动三方应用

1.让自己成为被打开第三方应用

1)添加对应的scheme。其中com.xinghaiwulian.XHWLHouseManager自己的app的BundleID, XHWL自定义的前缀(例如:http)

<key>CFBundleURLTypes</key>

<array>

<dict>

<key>CFBundleURLName</key>

<string>com.xinghaiwulian.XHWLHouseManager</string>

<key>CFBundleURLSchemes</key>

<array>

<string>XHWL</string>

</array>

</dict>

</array>

2)在自己的appDelegate中添加如下代码。其中 XHWL://为上面添加的scheme。

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {

        let prefix:String = "XHWL://"

        

        let range:NSRange = url.absoluteString.range(of: prefix) asNSRange

        if (range.location != NSNotFound) {

            let action:String = url.absoluteString.substring(from: String.Index(prefix.length()))

            if (action == "GotoHomePage") {

                

            }

            else if(action == "GotoOtherPage") {

                

            }

        }

        return true

    }


2.其他app调用第三方app

NSURL *url = [NSURL URLWithString:@"myapp:"];
[[UIApplication sharedApplication] openURL:url];
3.系统自带的调用三方






猜你喜欢

转载自blog.csdn.net/weixin_40873814/article/details/78986696