ios - 从 ACAccountStore/ACAccount 检索 Facebook token 过期?

标签 ios facebook ios6

在使用 ACAccountStoreACAccount 时,有什么方法可以判断您的 Facebook token 何时过期?

我创建了一个 ACAccountStore,获得了对用户 facebook 帐户的访问权限,将该帐户存储在一个 ACAccount 对象中,并且能够从凭据中检索 token 。不过,我还想知道此 token 何时过期。我将如何取消此 token 的到期时间?或者有可能吗?

最佳答案

您为什么想知道什么时候到期?

当您获得 token 时,就 Facebook 而言,它的 token 生命周期会延长。我认为今天这是额外的 60 天。因此,当您从帐户商店获得它时,就可以开始使用了。

如果用户正在使用您的应用程序,然后决定撤销 Facebook 设置本身的权限,您应该关注的唯一细节。

在这种情况下,您需要确保正在监视 ACAccountStoreDidChangeNotification 通知并适本地调用 renewCredentialsForAccount:completion: 以再次请求权限,请参阅 Documentation .

例如:

- (void)accountChanged:(NSNotification *)note
{
    [self.accountStore renewCredentialsForAccount:(ACAccount *)self.facebookAccount completion:^(ACAccountCredentialRenewResult renewResult, NSError *error){
        if(!error)
        {
            switch (renewResult) {
                case ACAccountCredentialRenewResultRenewed:
                    // Good
                    break;
                case ACAccountCredentialRenewResultRejected:
                    // Maybe go back to non logged in status
                    break;
                case ACAccountCredentialRenewResultFailed:
                    // Maybe internet failed, Facebook is down?
                    break;
                default:
                    break;
            }

        }
        else{
            // Handle error gracefully
        }
    }];
}

也许 this tutorial可能对您有所帮助。

关于ios - 从 ACAccountStore/ACAccount 检索 Facebook token 过期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17175298/

相关文章:

css - Facebook "Like"按钮(框样式)会增加分隔线布局中的宽度?

javascript - 捕获 Facebook 评论框的关闭或发布到 Facebook 事件

iphone - 在单键 NSMutableDictionary 下添加两个对象

ios - 如何在 UICollectionViewCell 中使用详细信息披露按钮?

iOS 照片从分享扩展上传,上传完成后回复

iphone - 在 iPhone 上安装自定义企业应用程序时配置文件错误

ios - Twitter官方iOS应用如何使用自定义文本更改状态栏

ios - 如何使用 UISplitViewController 在详细 View Controller 中获取主视图 Controller ?

php - 被 Facebook Chat API 标记为垃圾邮件的消息

iphone - iOS Safari 页面上方奇怪的灰色空间