iOS 上的 OAuth.io 缓存 [英] OAuth.io Caching on iOS

查看:57
本文介绍了iOS 上的 OAuth.io 缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次调用 OAuth.io 模式对话框时都会出现,即使我设置了缓存选项 (参见:在此处使用缓存).这是我基于 Swift 的应用程序的代码片段:

The OAuth.io modal dialog shows up every time I call it, even if I setup the caching option (see: using the cache here). Here is a code snippet from my Swift-based application:

let options = NSMutableDictionary()
options.setObject("true" as NSString, forKey: "cache")
let oauthModal: OAuthIOModal = OAuthIOModal(key: config?.valueForKey("oauth_key") as String!, delegate: self, andOptions: options)
if (!oauthModal.cacheAvailableForProvider(self.provider)) {
    oauthModal.showWithProvider(self.provider)
}

对话框显示得很好,我能够完成整个流程,但 cacheAvailableForProvider 永远不会返回 true.我确认我的应用能够在缓存目录中创建文件,但在模拟器中运行它后,我从未看到创建 oauthio-provider.json 文件.

The dialog shows up just fine, and I am able to go through the whole flow, but cacheAvailableForProvider never returns true. I confirmed that my app is able to create files in the caches directory, but after running it in the simulator, I never see an oauthio-provider.json file get created.

注意:第二次弹出对话框时,Safari 确实记得我登录到提供程序,但我的印象是缓存应该阻止对话框一起弹出.

NOTE: the second time the dialog pops up, Safari does remember my login to the provider, but I was under the impression that caching was supposed to stop the dialog from popping up all together.

我做错了什么?

推荐答案

在查看您的代码后,我意识到您将包含缓存字段的 options 字典提供给 OAuthIOModal 构造函数.

After reviewing your code, I realized that you gave the options dictionary containing the cache field to the OAuthIOModal constructor.

你应该把这个字典给 oauthModal.showWithProvider 方法,像这样:

You should give this dictionary to the oauthModal.showWithProvider method, like this:

modal.showWithProvider(self.provider, options:options)

希望对你有帮助

祝你有美好的一天.

这篇关于iOS 上的 OAuth.io 缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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