Facebook authorization fails on iOS6 when switching FB account on device

后端 未结 6 2110
难免孤独
难免孤独 2020-11-28 04:14

I\'m using die Facebook SDK 3.1.1 to implement FB Connect in my iOS application. This works fine in the simple case with either the new FB integration (logged in on iOS) or

6条回答
  •  情深已故
    2020-11-28 04:34

    In ios 6 with fb sdk 3.1.1. Please pass permissions param as "nil or email" in "[FBSessio openActiveSessionWithReadPermissions..." method. Here my code it was works great.

    #define IOS_NEWER_OR_EQUAL_TO_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] >= 6.0 )
    
    -(void)showFBLogin
    {
        [FBSession.activeSession closeAndClearTokenInformation];
    
        NSArray *permissions = [NSArray arrayWithObjects:@"email, publish_actions, publish_stream", nil];
    
    #ifdef IOS_NEWER_OR_EQUAL_TO_6
        permissions = nil; or NSArray *permissions = [NSArray arrayWithObjects:@"email",nil];
    #endif
    
        NSLog(@"\npermissions = %@", permissions);
        [FBSession openActiveSessionWithReadPermissions:permissions
                                           allowLoginUI:YES
                                      completionHandler:
         ^(FBSession *session,
           FBSessionState state, NSError *error) {
             NSLog(@"\nfb sdk error = %@", error);
             switch (state) {
                 case FBSessionStateOpen:
                     [[FBRequest requestForMe] startWithCompletionHandler:
                      ^(FBRequestConnection *connection, NSDictionary *user, NSError *error) {
                          if (!error) {
                              //success
                          } 
                      }];
                     break;
                 case FBSessionStateClosed:
                     //need to handle
                     break;
                 case FBSessionStateClosedLoginFailed:
                     //need to handle
                     break;
                 default:
                     break;
             }
         }];
    }
    

提交回复
热议问题