Facebook SDK的FBSDKShareDialog无法在iOS9上运行? [英] FBSDKShareDialog of Facebook SDK is not working on iOS9?

查看:629
本文介绍了Facebook SDK的FBSDKShareDialog无法在iOS9上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Xcode7,我将Facebook SDK升级到pod FBSDKShareKit(4.6.0)。我已将Facebook方案添加到WhiteList,如下所示。
参考: https://developers.facebook.com/docs/ios/ios9

With Xcode7, I upgrade Facebook SDK to pod FBSDKShareKit (4.6.0). And I have added Facebook scheme to WhiteList as below. reference: 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应用程序并正确显示共享对话框。

However, the following code only show iOS default social dialog on iOS9. The same code with the same binary on iOS8 can open Facebook app and show the Sharing Dialog properly.

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应用,然后显示默认的社交对话框。甚至没有显示错误信息。

I guess Facebook app is not found on iOS9 and then show the default social dialog. Even no error message showed.

我是否会错过任何内容?或者,这是一个iOS9错误?

Do I miss anything? Or, it's an iOS9 bug?

推荐答案

我猜Facebook改变了行为,因为iOS 9现在弹出一个对话框询问是否你想打开Facebook?在进行app切换时即使对于FBSDKLoginManager,应用程序切换(本机)方法似乎也不如模态UIWebView优先。

I'm guessing Facebook changed the behaviour because iOS 9 now pops up a dialog asking if you would like to "Open Facebook?" when doing app-switching. Even for FBSDKLoginManager, the app-switching (native) method seems to be less preferred than a modal UIWebView.

但是,您仍然可以强制共享对话框切换到Facebook应用程序(假设您的应用程序plist设置如 https://developers.facebook.com/docs/ios/ios9中所述) )使用此方法:

However, you can still force the share dialog to switch to the Facebook app (assuming you have your application plist setup as described in https://developers.facebook.com/docs/ios/ios9) by using this method:

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];

这篇关于Facebook SDK的FBSDKShareDialog无法在iOS9上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆