Facebook 3.1iOSSDKで公開権限を使用してログインできません。
私のアプリにはビデオを共有するためのボタンがあり、ユーザーがそれをクリックしたときに、基本的な+公開権限を追加したいと思います。私が理解しているように、私は2つの呼び出しを行う必要があります-
openActiveSessionWithReadPermissions
、 その後reauthorizeWithPublishPermissions
これが私が今使っているコードです:
//Opens a Facebook session and optionally shows the login UX.
- (void)openSessionForReadPermissions
{
[FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
//this is called even from the reauthorizeWithPublishPermissions
if (state == FBSessionStateOpen && !error)
{
[self openSessionForPublishPermissions];
}
else if (state == FBSessionStateClosedLoginFailed)
{
[FBSession.activeSession closeAndClearTokenInformation];
[[NSNotificationCenter defaultCenter] postNotificationName:FBLoginErrorNotification object:session];
}
}];
}
-(void)openSessionForPublishPermissions
{
NSArray* permissions = [NSArray arrayWithObject:@"publish_stream"];
[[FBSession activeSession] reauthorizeWithPublishPermissions:permissions
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:
^(FBSession *session, NSError *error)
{
if (!error)
{
[[NSNotificationCenter defaultCenter]
postNotificationName:FBLoginSuccessNotification
object:session];
}
else
{
[[NSNotificationCenter defaultCenter]
postNotificationName:FBLoginErrorNotification
object:session];
}
}];
}
openSessionForReadPermissionsのブロックが2回呼び出され(1回はFBSessionStateOpenで、もう1回はopenSessionForPublishPermissions呼び出しからFBSessionStateOpenTokenExtendedで)、最初にアプリにログインしようとするとErrorReauthorizeFailedReasonUserCancelledが発生します(Oが以前にすべてのアプリのアクセス許可を削除した場合)。
このログインを実装する適切な方法は何ですか?この1つの機能を除いて、アプリはFacebookログインを必要としないため、ログインプロセスは同じボタンを押すだけで行う必要があります。
ありがとう!