Facebook logging into wrong app on iOS

0 votes

My iOS app uses Facebook for logging in, however my dev team recently decided to consolidate all our apps into one universal Facebook app with a common APP ID. So I went into my project and tried to change my FacebookAppID and URL Types to the right APP ID, but when I run the app and click on the login button, it redirects me to log into my old app on Facebook. I have absolutely no idea 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];
}

Nov 22, 2022 in Mobile Development by gaurav
• 23,260 points
475 views

1 answer to this question.

0 votes

The issue may be caused by various reasons, e.g. improper cookie settings, another person may be trying to log into your Facebook account, Facebook session expired, corrupt or wrong browser caches, malware or virus infection, etc.

answered Dec 15, 2022 by gaurav
• 23,260 points

Related Questions In Mobile Development

0 votes
0 answers

Facebook iOS 9 SDK login redirects to mbasic.facebook.com on Safari

I'm using the iOS 9 Facebook SDK to manage ...READ MORE

Nov 8, 2022 in Mobile Development by gaurav
• 23,260 points
1,343 views
0 votes
0 answers

Opening Instagram app from a link on iOS

I am providing a feed which is ...READ MORE

Nov 8, 2022 in Mobile Development by gaurav
• 23,260 points
1,118 views
0 votes
0 answers

How facebook measure app installs - Android/IOS

Facebook ads has a feature that it ...READ MORE

Nov 10, 2022 in Mobile Development by gaurav
• 23,260 points
512 views
0 votes
0 answers

How to open app from Twitter for iOS WebView on iOS 9

My question pertains to deeplinking from a ...READ MORE

Nov 10, 2022 in Mobile Development by gaurav
• 23,260 points
587 views
0 votes
1 answer

Getting country calling prefix

For a class that offers both this ...READ MORE

answered Sep 20, 2022 in Others by Aditya
• 7,680 points
841 views
0 votes
1 answer

white screen on simulator iphone Xcode

After creating the request, you must actually ...READ MORE

answered Sep 20, 2022 in Others by Aditya
• 7,680 points
3,909 views
0 votes
1 answer

Is there a way to to check if a picture was taken on that iPhone?

Actually, the model and manufacturer information is ...READ MORE

answered Sep 22, 2022 in IOS by Rahul
• 9,680 points
662 views
0 votes
1 answer

iOS Post to Facebook shows m.facebook.com

From your Feed, tap Search Facebook at ...READ MORE

answered Nov 4, 2022 in Others by gaurav
• 23,260 points
490 views
0 votes
1 answer

Flutter project in iOS emulator takes forever to run, but its worked on Android emulator

Try flutter clean and flutter build ios ...READ MORE

answered Nov 18, 2022 in Mobile Development by gaurav
• 23,260 points
669 views
0 votes
1 answer

Open webpage in fullscreen in Safari on iOS

Not all platforms are equal. iOS Safari doesn't ...READ MORE

answered Nov 25, 2022 in Mobile Development by gaurav
• 23,260 points
670 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP