问题描述
将我们的Facebook iOS集成从2.x SDK升级到3.x SDK会自动注销以前登录的用户,因为我们以前必须手动处理的身份验证凭据现在已在后台处理通过新的SDK.
Upgrading our Facebook iOS integration from the 2.x SDK to 3.x SDK automatically logs users out who were previously logged in, since the authentication credentials that we used to have to manually handle ourselves are now handled behind-the-scenes by the new SDK.
作为一次性身份验证迁移,是否有任何方法可以强制3.x SDK使用我们之前手动存储的访问令牌和到期日期进行身份验证?
Is there any way to force the 3.x SDK to authenticate using the access token and expiration date that we were previously manually storing, as a one-time authentication migration?
提前谢谢!
推荐答案
最后弄清楚了.该解决方案涉及使用他们提供的 FBSessionTokenCachingStrategy 对象,特别是一个 FBSessionManualTokenCachingStrategy :
Finally figured it out. The solution involves using the FBSessionTokenCachingStrategy object they provide, and specifically an FBSessionManualTokenCachingStrategy:
if (isUserUpgrading) {
FBSessionTokenCachingStrategy *strategy = [[[FBSessionManualTokenCachingStrategy alloc] initWithUserDefaultTokenInformationKeyName:nil] autorelease];
strategy.accessToken = [[NSUserDefaults standardUserDefaults] stringForKey:@"FBSessionToken"]; // use your own UserDefaults key
strategy.expirationDate = [[NSUserDefaults standardUserDefaults] objectForKey:@"FBSessionExpiration"]; // use your own UserDefaults key
FBSession *session = [[[FBSession alloc] initWithAppID:@"MY_APP_ID" // use your own appId
permissions:nil
urlSchemeSuffix:nil
tokenCacheStrategy:strategy] autorelease];
[FBSession setActiveSession:session];
} else {
[FBSession openActiveSessionWithReadPermissions:...]; // normal authentication
}
这篇关于从iOS Facebook 2.x迁移时如何避免注销用户-> 3.x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!