xcode iOS Facebook SDK 3.1 登录时添加权限
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12955635/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS Facebook SDK 3.1 add permission when login
提问by EES
I am trying to follow the Facebook SDK 3.1 tutorial: Scrumptious and integrate FB to my app.
我正在尝试遵循 Facebook SDK 3.1 教程:美味并将 FB 集成到我的应用程序。
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = @[@"email"];
return [FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
I want to add extra permission however it only show the basic information in the authentication as the following image:
我想添加额外的权限,但它只显示身份验证中的基本信息,如下图:
I also used deprecated method and I got the same result:
我还使用了不推荐使用的方法,但得到了相同的结果:
[FBSession openActiveSessionWithPermissions:permissions allowLoginUI:allowLoginUI completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
I found temporary solution from hereby using reauthorizeWithPublishPermissions
in somewhere else. The user have to login to the facebook twice to read the user email.
我通过在其他地方使用,从这里找到了临时解决方案reauthorizeWithPublishPermissions
。用户必须两次登录 Facebook 才能阅读用户电子邮件。
Is there any solution which I can do it in once?
有什么解决方案可以一次性完成吗?
Thanks for helping!
感谢您的帮助!
EDIT: Another poston stackoverflow, using openActiveSessionWithPublishPermissions
, still have the same result as the screenshot.
编辑:关于 stackoverflow 的另一篇文章,使用openActiveSessionWithPublishPermissions
,仍然具有与屏幕截图相同的结果。
采纳答案by runmad
I would check the permissions on Facebook.com in the Facebook app's permission settings and make sure they match. I do believe they say you can set the permissions in your iOS code, but I would recommend matching the permissions in the FB app settings as well.
我会在 Facebook 应用程序的权限设置中检查 Facebook.com 上的权限,并确保它们匹配。我相信他们说您可以在 iOS 代码中设置权限,但我建议您也匹配 FB 应用程序设置中的权限。
回答by Snaker
According to the Facebook FBSession Reference, as a best practice, you should ask for read permissions when opening the session. And then ask for additional permissions later on, when you need them.
根据Facebook FBSession Reference,作为最佳实践,您应该在打开会话时请求读取权限。然后在以后需要时请求其他权限。
It is required that initial permissions requests represent read-only permissions only.
要求初始权限请求仅代表只读权限。
Secondly, I tried this code below, and I get the right permission requirement.
其次,我在下面尝试了此代码,并且获得了正确的权限要求。
NSArray *permissions = [[NSArray alloc] initWithObjects:@"email", nil];
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];}];
[permissions release];
Hope this helps.
希望这可以帮助。
回答by iArezki
http://developers.facebook.com/docs/reference/login/#permissions
http://developers.facebook.com/docs/reference/login/#permissions
this is an example how to use them
这是如何使用它们的示例
NSArray *permissions = [[NSArray alloc] initWithObjects:@"publish_stream", @"email", nil];
[facebook authorize:permissions];
[permissions release];