更新时间:2022-12-30 23:36:12
我认为这是不可能直接实现的,但如果应用程序注册了 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"]];
}