Facebook logs in wrong iOS app

My iOS application uses Facebook to log in, however, my development team recently decided to combine all our applications into one universal Facebook application with a common APP identifier. So I went into my project and tried to change my FacebookAppID and URL types to the correct APP ID, but when I started the application and clicked on the login button, it redirects me to login to my old Facebook application. I don’t know why this is happening, but here is what I have in my AppDelegate file:

/*
 Callback for session changes
*/
- (void)sessionStateChanged:(FBSession *)session
                  state:(FBSessionState) state
                  error:(NSError *)error
{
switch (state) {
    case FBSessionStateOpen:
        if (!error) {
            // We have a valid session
            NSLog(@"User session found");
        }
        break;
    case FBSessionStateClosed:
    case FBSessionStateClosedLoginFailed:
        [FBSession.activeSession closeAndClearTokenInformation];
        break;
    default:
        break;
}

[[NSNotificationCenter defaultCenter]
 postNotificationName:FBSessionStateChangedNotification
 object:session];

if (error) {
    UIAlertView *alertView = [[UIAlertView alloc]
                              initWithTitle:@"Error"
                              message:error.localizedDescription
                              delegate:nil
                              cancelButtonTitle:@"OK"
                              otherButtonTitles:nil];
    [alertView show];
    }
}

/*
 * Opens a Facebook session and optionally shows the login UX.
 */
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
    NSArray *permissions = [[NSArray alloc] initWithObjects:
                        @"email",
                        @"user_games_activity",
                        @"user_location",
                        @"user_likes",
                        @"user_birthday",
                        nil];
return [FBSession openActiveSessionWithReadPermissions:permissions
                                          allowLoginUI:allowLoginUI
                                     completionHandler:^(FBSession *session,
                                                         FBSessionState state,
                                                         NSError *error) {
                                         [self sessionStateChanged:session
                                                             state:state
                                                             error:error];
                                     }];
}

/*
 * If we have a valid session at the time of openURL call, we handle
 * Facebook transitions by passing the url argument to handleOpenURL
 */
- (BOOL)application:(UIApplication *)application
        openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
     annotation:(id)annotation {
    // attempt to extract a token from the url
    return [FBSession.activeSession handleOpenURL:url];
}
/*
 *Logout
 *
 */
- (void) closeSession {
    [FBSession.activeSession closeAndClearTokenInformation];
}
+5
source share
1 answer

, , , URL- Facebook Info.plist. :

  • , URL- Facebook Info.plist.

URL. , , fbxxxxxxxxxxx, http://developers.facebook.com/

+6

All Articles