iOS: Facebook Login access token error: Falling ba

2019-04-29 13:59发布

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.
        NSLog(@"test");
    }
    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]);
}

2条回答
兄弟一词,经得起流年.
2楼-- · 2019-04-29 14:39

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];

查看更多
冷血范
3楼-- · 2019-04-29 14:50

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

查看更多
登录 后发表回答