迁移现有访问令牌给Facebook的iOS SDK 3.0 [英] Migrating existing access tokens to Facebook iOS SDK 3.0

查看:155
本文介绍了迁移现有访问令牌给Facebook的iOS SDK 3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚去就我的codeBase的使用新的Facebook-IOS-SDK 3.0(从previous版本2.x或诸如此类的东西)。

I just overhauled my codebase to use the new facebook-ios-sdk 3.0 (from the previous version, 2.x or whatnot).

一切伟大的工作,直到我意识到我没有占到谁已经授予应用程序权限的用户/登录时使用的previous实施的SDK。所以,我想检查,看看是否的accessToken保存在NSUserDefaults的,如果是这样,拨打电话打开会话:

Everything worked great, until I realized I hadn't accounted for users who had already granted the app permission/logged in with the previous implementation of the SDK. So I tried checking to see if the accessToken was saved in NSUserDefaults, and if so, make a call to open a session:

    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"FBAccessTokenKey"] &&
        [[NSUserDefaults standardUserDefaults] objectForKey:@"FBExpirationDateKey"]) {
        [FBSession openActiveSessionWithPermissions:permissions
                                       allowLoginUI:allowLoginUI
                                   completionHandler:^(FBSession *session,
                                                       FBSessionState status,
                                                       NSError *error) {
         // deal with state change
         }

我的假设是,用户不会有快速应用程序切换为SSO,因为他们已经有了。然而,这确实是发生了什么。

My assumption was that the user wouldn't have to fast app switch for SSO, since they already had. However, that is indeed what happens.

我宁愿没有每一个现有的用户需要重新登录升级时。

I'd rather not have every existing user need to re-login when upgrading.

有没有人成功升级,而无需重新登录?

Has anyone successfully upgraded without having to re-login?

感谢

推荐答案

我已经升级与Facebook的SDK 3.0的应用程序和它的工作就好了。 Facebook的SDK处理令牌本身,但你仍然可以访问的accessToken。

I have upgraded an app with the facebook SDK 3.0 and it worked just fine. The Facebook SDK handles the token itself, but you can still access the accessToken.

您可以到达任何时候像这样:

You can reach it any time like so:

NSString *accessToken = [FBSession activeSession].accessToken;

如果没有标记设置这将返回的accessToken或一个零。你甚至可以定义的会话令牌缓存规则集。享受。

This will return the accessToken or a nil if no token is set. You can even define a token caching ruleset on the session. Enjoy.

这篇关于迁移现有访问令牌给Facebook的iOS SDK 3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆