检测是否从另一个应用程序中安装了iOS应用程序

检测是否从另一个应用程序中安装了iOS应用程序

问题描述:

我的iOS应用程序上有一个按钮,该按钮将通过深度链接启动第三方应用程序,但是如果未安装该应用程序,则该按钮将无任何作用。

I have a button on my iOS app that will launch a third party app via deeplinking, but if said app is not installed, the button will not do anything.

如何检查是否先安装了该应用程序,如果未安装,则提示用户下载该应用程序?

How can I check if the app is installed first, if not, prompt the user to download it?

按钮代码:

@IBAction func didTapEdmodo(sender: AnyObject) {
    UIApplication.sharedApplication().openURL(NSURL(string: "edmodo://")!)
}


您可以调用 canOpenURL:进行检查。请注意,在发出请求之前,需要在info.plist中声明URL方案。这是通过 LSApplicationQueriesSchemes 键完成的。

You can call canOpenURL: to check. Note that you need to declare the URL scheme in your info.plist before you can make the request. This is done using the LSApplicationQueriesSchemes key.