【发布时间】:2014-08-13 19:21:29
【问题描述】:
我遇到了 requestNewPublishPermissions 的问题(我使用的是 SDK 版本 3.17)。 Facebook 文档说只需读取权限即可登录,然后再请求写入权限,这就是我想要做的。我可以使用如下代码让用户正常登录:
[FBSession openActiveSessionWithReadPermissions:@[@"public_profile"]
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error)
{
// Handler for session state changes
// This method will be called EACH time the session state changes,
// also for intermediate states and NOT just when the session open
[self sessionStateChanged:session state:state error:error];
}];
然后,当我想发布到时间线时,我要求使用下面的代码扩展权限。该应用程序通过 Facebook 网页启动到 Safari。但是,该网页并没有要求写权限,而是说该应用程序已经获得了许可。然后当我点击确定,控制权返回到应用程序时,我没有发布权限。见“这就是它结束的地方!”下面。
我已尝试访问 facebook.com 并删除“应用程序”下已授予的权限。那没有任何区别。无论如何,我也尝试过发布,但这给了我一个错误,说我没有正确的权限。
有什么想法吗?
- (void) requestPublishPermission:(void (^)(void)) action
{
// Request publish_actions
[FBSession.activeSession requestNewPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error)
{
if (!error)
{
if ( [FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound )
{
// this is where it ends up!
}
else
{
// Permission granted, publish the story
action();
}
}
else
{
// permission denied, alert user
}
}];
}
【问题讨论】:
-
我现在也有同样的问题X(你找到解决办法了吗??
-
不,我从来没有这样做过。 IIRC,我使用原生 Facebook 共享 GUI 作为解决方法。
-
我明白了,非常感谢!