How to check programmatically if an App is installed?(如果安装了应用程序,如何以编程方式检查?)
问题描述
我正在开发一个 iPhone 应用程序,它将在企业中安装少量第三方应用程序.我有关于捆绑 ID 的信息.有没有办法使用一些系统 API 来检查应用程序是否已经安装?目前应用程序再次安装,覆盖当前安装.我需要以某种方式防止这种情况.(如果应用程序已经安装,Apple 的 AppStore 应用程序会禁用安装选项.)
I am developing an iPhone application which will install few third party applications in an enterprise. I have the information about the bundle IDs. Is there a way to check if the application is already installed, using some system APIs? Currently the application gets installed again, overwriting the current installation. I need to prevent this some how. (Apple's AppStore application disables the installation option if the app is already installed.)
推荐答案
我认为这是不可能直接实现的,但如果应用程序注册了 uri 方案,您可以对此进行测试.
I think this is not possible directly, but if the apps register uri schemes you could test for that.
一个 URI 方案例如是 Facebook 应用程序的 fb://
.您可以在应用程序的 info.plist 中注册它.[UIApplication canOpenURL:url]
会告诉你某个 url 是否会打开.因此,如果测试 fb://
是否会打开,将表明安装了一个注册了 fb://
的应用程序 - 这对 facebook 应用程序来说是一个很好的提示.
A URI scheme is for example fb://
for the facebook app. You can register that in the info.plist of your app. [UIApplication canOpenURL:url]
will tell you if a certain url will or will not open. So testing if fb://
will open, will indicate that there is an app installed which registered fb://
- which is a good hint for the facebook app.
// check whether facebook is (likely to be) installed or not
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]]) {
// Safe to launch the facebook app
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"fb://profile/200538917420"]];
}
这篇关于如果安装了应用程序,如何以编程方式检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如果安装了应用程序,如何以编程方式检查?


基础教程推荐
- 如何使用 YouTube API V3? 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01