[Solved] iOS: Facebook Login access token error: Falling back to loading access token from NSUserDefaults because of simulator bug

After configuring it based on the instructions I keep on getting this error and I am unable to successfully use Facebook Login on my app. I am running it on XCode 8.1 and using an iOS 10.1 simulator.

I followed the steps on the Facebook iOS SDK guide and put the Facebook login button in my view controller. I displayed the NSUserdefaults and one of the keys is “com.facebook.sdk:serverConfiguration” so I believe it is saving there.

- (void)viewDidLoad {
    [super viewDidLoad];
    if ([FBSDKAccessToken currentAccessToken]) {
        // User is logged in, do work such as go to next view controller.
    else {
        FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
        loginButton.center = self.view.center;
        [self.view addSubview:loginButton];
    _loginButton.readPermissions =
    @[@"public_profile", @"email", @"user_friends"];
    NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
Enquirer: SabCo


Solution #1:

If the problem is that the iOS Simulator is signed out after a restart of the app, this is caused by a bug in the Facebook SDK. It prevents the simulator from caching the access token.

You can fix this by adding the following line:

key = [NSString stringWithFormat:@"%@_fix", key];

in FBSDKKeychainStore.m:94 and FBSDKKeychainStore.m:135
just before:

[[NSUserDefaults standardUserDefaults] setObject:value forKey:key];

Respondent: Jorn van Dijk

Solution #2:

To get rid of these rather annoying log messages (that’s all they are), go to FBSDKCoreKit’s FBSDKKeychainStore.m file and comment lines 93 and 134:

//NSLog(@"Falling back to storing access token in NSUserDefaults because of simulator bug");

Voilá… gone!

Note: This is current for Facebook SDK for iOS version 4.23.0.

For CocoaPods:
The file can be found in your Xcode workspace under:
Pods > Pods > FBSDKCoreKit > FBSDKKeychainStore.m

Respondent: Emilio Barcelos

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.