简体   繁体   English

如何使用SDK 3.1在iOS上获取本机Facebook登录?

[英]How to get native Facebook login on iOS using SDK 3.1?

I downloaded the new Facebook iOS SDK 3.1 , which promises to have a native login prompt . 我下载了新的Facebook iOS SDK 3.1 ,该软件承诺会有一个本机登录提示 I ran their sample login app on my iOS 6 device. 我在iOS 6设备上运行了他们的示例登录应用程序。 When I attempted to connect with Facebook, I did not get a native login. 当我尝试连接Facebook时,没有获得本机登录。 Instead, the Facebook app launched - same as the old SDK. 相反,Facebook应用程序启动了-与旧版SDK相同。 Their Facebook login button basically does this: 他们的Facebook登录按钮基本上是这样做的:

[appDelegate.session 
    openWithCompletionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
        [self updateView];
    }
];

I thought maybe the sample code isn't calling the right function. 我以为示例代码可能没有调用正确的函数。 So I tried FBSession 's other login function. 所以我尝试了FBSession的其他登录功能。

[appDelegate.session 
    openWithBehavior:FBSessionLoginBehaviorWithNoFallbackToWebView 
    completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
        [self updateView];
    }
];

I tried all possible behaviours and none of them popped up the native login prompt. 我尝试了所有可能的行为,但没有一个弹出本机登录提示。

Did you log into Facebook from the iOS settings first? 您是否首先从iOS设置登录了Facebook?

Once you do that, their example project Scrumptious will use the native login prompt when you try to connect. 完成后,当您尝试连接时,他们的示例项目Scrumptious将使用本机登录提示。

Read this: https://developers.facebook.com/docs/howtos/ios-6/#nativeauthdialog 阅读此内容: https : //developers.facebook.com/docs/howtos/ios-6/#nativeauthdialog

Basically you must request basic permissions and read permissions first and then request publish permissions separately. 基本上,您必须先请求基本权限并先阅读权限,然后再分别请求发布权限。

This is by design, and described in the second section of https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/3.1/upgrading-from-3.0/ 这是设计使然,并在https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/3.1/upgrading-from-3.0/

Basically, you are not able to ask for both read and publish permissions with the iOS6 dialog. 基本上,您无法使用iOS6对话框同时要求读取和发布权限。 Therefore you are more-or-less required to ask for them in a staggered way (eg read on first login, and then publish when your app actually needs to publish). 因此,您或多或少需要以交错的方式询问它们(例如,在首次登录时阅读,然后在实际需要发布应用程序时发布)。

If you insist on using the deprecated method to try and get read & publish at the same time, the SDK has no choice but to return to the web or app-switched technique. 如果您坚持使用不推荐使用的方法来尝试同时读取和发布,则SDK除了返回Web或应用程序切换技术外别无选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM