BOOL isInstalled = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]]
if (isInstalled) {
} else {
}
以上代码适用于iPhone但不适用于iPad。
答案 0 :(得分:6)
首先,您需要将白名单'通过将以下内容添加到Info.plist
文件
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fb</string>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
并检查
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]]) {
// Facebook app is installed
}else
{
// not installed
}