如何以编程方式检查是否安装了应用程序?
我正在开发一个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方案例如是 fb://
对于Facebook应用程序。您可以在应用的info.plist中注册。 [UIApplication canOpenURL: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"]];
}