iOS:Facebook登录访问令牌错误:由于模拟器错误,从NSUserDefaults返回加载访问令牌 [英] iOS: Facebook Login access token error: Falling back to loading access token from NSUserDefaults because of simulator bug
问题描述
根据我继续收到此错误的说明进行配置后,我无法在我的应用上成功使用Facebook登录。我正在XCode 8.1上运行,并使用iOS 10.1模拟器。
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.
我按照Facebook iOS SDK指南中的步骤,将Facebook登录按钮放在我的视图控制器中。我显示了NSUserdefaults,其中一个关键是com.facebook.sdk:serverConfiguration,所以我相信它正在保存。
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]);
}
推荐答案
如果问题是iOS模拟器在重新启动应用程序后退出,这是由Facebook SDK中的错误引起的。它可以防止模拟器缓存访问令牌。
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];
在 FBSDKKeychainStore.m:94
和 FBSDKKeychainStore.m:135
就在之前:
in FBSDKKeychainStore.m:94
and FBSDKKeychainStore.m:135
just before:
[[NSUserDefaults standardUserDefaults] setObject:value forKey:key];
这篇关于iOS:Facebook登录访问令牌错误:由于模拟器错误,从NSUserDefaults返回加载访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!