[英]FBSDKShareDialog of Facebook SDK is not working on iOS9?
使用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错误?
我猜Facebook改变了行为,因为iOS 9现在弹出一个对话框,询问你是否想要“打开Facebook?” 在进行app切换时。 即使对于FBSDKLoginManager,app-switching(本机)方法似乎也不如模态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];
在iOS 9中,下面是唯一能够检测到facebook app是否安装在设备中的解决方案:
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"]];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.