How to detect if Facebook app is installed on iOS? [duplicate]

旧时模样 提交于 2019-12-09 04:41:01

问题


On iOS, you can launch the Facebook app and link to a profile by opening a url like this: fb://profile/12345

The only problem is that if the Facebook app isn't installed, nothing happens.

Is there a way to detect if the app is installed or if the url scheme fb:// is supported?

This would apply broadly to other apps like Twitter as well.


回答1:


BOOL isInstalled = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]]

if (isInstalled) {

} else {

}



回答2:


Try just using the canOpenURL: function

NSURL *fbURL = [NSURL URLWithString:@"fb://"];//or whatever url you're checking

if ([[UIApplication sharedApplication] canOpenURL:fbURL])
{
  //open it etc  
}


来源:https://stackoverflow.com/questions/19690170/how-to-detect-if-facebook-app-is-installed-on-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!