iPhone:如何使用 Facebook Graph api 保存会话
我对 iPhone 开发还比较陌生,我正在尝试在我的应用程序中实现 Facebook 功能。我尝试了 Facebook connect DemoApp,但它似乎没有保存我的会话。每次重新启动应用程序时我都必须登录。如何在我的应用程序中实现会话保存?我已经搜索了很多,但仍然没有找到一个简单的方法来做到这一点。谢谢
Im relatively new to iPhone development and Im trying to implement Facebook functions in my app. I tried the Facebook connect DemoApp, but it doesn't seem to save my session. I have to login everytime I restart my app. How do I implement session saving in my app? I have searched a lot but still haven't found a simple way to do this. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要请求“offline_access”权限。否则,您的令牌将过期并需要使用新的登录进行刷新。如果您获得离线权限,则在图形客户端明确注销之前,您获得的令牌一直有效。
You need to request "offline_access" permission. Otherwise your token expires and needs to be refreshed with a new login. If you get offline permission, the token you're given is good until the graph client is explicitly logged out.
看看 FBConnect 的 FBLoginDialog.m 文件中的这个
[_sessionresume];
...你会发现在这个方法中。这个负责查看是否存在....还可以从 Facebook Connect 教程
祝你好运!
Have a look on this
[_session resume];
in your FBLoginDialog.m file of the FBConnect....you will find that in this method.This one is responsible for thatSee that is there or not ....also take help from Facebook Connect Tutorial
Good Luck!
facebook iPhone api 自动保存会话。您只需在分配并初始化 FBSession 对象后调用
[sessionresume];
即可。如果没有任何东西要加载,什么也不会发生。The facebook iPhone api automatically saves the session. You simply have to call
[session resume];
after alloc'ing and init'ing an FBSession object. If there was nothing to load nothing will happen.会话保存和会话恢复似乎已从最新的 facebook connect iphone sdk 中删除。事实上,在旧的 sdk 中,访问会话对象是访问 facebook 的主要方式,而在新的 sdk 中,则全部通过“facebook”类。我见过使用新 sdk 保存和恢复会话的游戏,所以我知道这是可能的,希望我能告诉你它是如何工作的。
好吧,从头开始,我想出了如何使用新的 SDK 来做到这一点,您可以将传递到应用程序 openurl 的整个 url 保存到 plist 中,然后下次应用程序重新启动时,它可以读取该字符串并将其传递到 facebook无需使用授权例程。
session save and session resume seems to have been removed from the latest facebook connect iphone sdk. In fact where in the old sdk access to the session object was the primary way to access facebook, in the new sdk its all through the 'facebook' class. I have seen games that use the new sdk saving and restoring the session though, so I know its possible, wish I could tell you how it works.
Alright scratch all that, I figured out how to do it with the new SDK, you can save the entire url passed into your applications openurl into the plist, then the next time your app reboots it can read that string and pass it into the facebook without needing to use the authorize routine.