在 Facebook iOS SDK 中存储 accessToken
我在我的应用程序中设置了 Facebook iOS SDK。但是,我无法确定会话何时结束。如何检查是否完成,以及在哪里(如何)存储登录收到的访问令牌?
我需要从一开始就确定我是否拥有访问令牌,以便我知道是否再次登录或在应用程序中继续。
I have the Facebook iOS SDK set up in my app. However, I have trouble determining when my session is finished. How to check if it's finished, and where (how) to store the access token received by the login?
I need to determine whether I have the access token or not right from the beginning so I know whether to log in again, or go forward in the app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你熟悉 NSUserDefaults 吗?它用于存储您的应用程序的首选项。
它们非常易于使用,可能正是您正在寻找的。所以这只是......
希望它有帮助!
一个将偏好设置为“factoids”,如上例
两个为您的偏好决定一个名称。示例中的“storeTheStringHere”。
三使用 stringForKey 获取示例中的字符串“whateverIDstring”:
四检查它是否为 nil 或空白。如果是这样,请重新开始。
五一旦获得该值,请按所示保存!
希望有帮助!
Are you familiar with NSUserDefaults ? It is for storing preferences for your app.
They are extremely easy to use, and probably what you are looking for. So it's just something like ..
Hope it helps!
ONE get the preferences in to 'factoids' as in the example above
TWO decide on a name for your preference. 'storeTheStringHere' in the example.
THREE get your string 'whateverIDstring' in the example using stringForKey:
FOUR check if it is either nil or blank. if so, start fresh.
FIVE once you get the value, save it as shown!
Hope it helps!