检测是否从另一个应用程序中安装了iOS应用程序 [英] Detect if iOS app is installed from within another app
本文介绍了检测是否从另一个应用程序中安装了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.
这篇关于检测是否从另一个应用程序中安装了iOS应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文