如何在iPad上安装fb app?

sha*_*khi 1 objective-c ipad ios

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

if (isInstalled) {

} else {

}
Run Code Online (Sandbox Code Playgroud)

以上代码适用于iPhone但不适用于iPad.

Anb*_*hik 7

首先,您需要通过在Info.plist文件中添加以下内容来将网址"列入白名单"

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fb</string>
    <string>fbapi</string>
    <string>fb-messenger-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
</array>
Run Code Online (Sandbox Code Playgroud)

并检查

 if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]]) {
    // Facebook app is installed
}else
{
 // not installed
 }
Run Code Online (Sandbox Code Playgroud)