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

拟墨画扇 提交于 2020-01-02 04:51:05

问题


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

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




回答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



来源:https://stackoverflow.com/questions/41047345/ios-facebook-login-access-token-error-falling-back-to-loading-access-token-fro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!