使用Xcode7,我将Facebook SDK升级到pod FBSDKShareKit (4.6.0)。我已经将Facebook方案添加到WhiteList中,如下所示。参考:https://developers.facebook.com/docs/ios/ios9
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>但是,以下代码仅显示iOS9上的iOS默认社交对话框。在iOS8上使用相同的二进制代码可以打开Facebook应用程序并正确显示共享对话框。
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.example.com"]];
content.contentDescription = @"Test";
[FBSDKShareDialog showFromViewController:self withContent:content delegate:nil];我猜在iOS9上找不到Facebook应用程序,然后显示默认的社交对话框。甚至没有显示错误消息。
我错过什么了吗?或者,这是一个iOS9错误?
发布于 2015-09-18 14:31:00
我猜脸书改变了这种行为,因为iOS 9现在弹出一个对话框,问你是否想要“打开脸书”?进行应用程序切换时。即使对于FBSDKLoginManager,应用程序切换(原生)方法似乎也不如模式UIWebView更受欢迎。
但是,您仍然可以使用以下方法强制共享对话框切换到Facebook应用程序(假设您已经按照https://developers.facebook.com/docs/ios/ios9中所述设置了应用程序plist ):
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fbauth2://"]]){
dialog.mode = FBSDKShareDialogModeNative;
}
else {
dialog.mode = FBSDKShareDialogModeBrowser; //or FBSDKShareDialogModeAutomatic
}
dialog.shareContent = content;
dialog.delegate = self;
dialog.fromViewController = self;
[dialog show];发布于 2016-08-26 14:16:30
在Facebook9中,下面是我检测iOS应用程序是否安装在设备上的唯一解决方案:
NSString *urlString = @"fbapi://";
NSURL *url1 = [NSURL URLWithString:urlString];
if ([[UIApplication sharedApplication] canOpenURL:url1]) {
[[UIApplication sharedApplication] openURL:url1];
}
else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itunes link for download app"]];
}https://stackoverflow.com/questions/32643522
复制相似问题