How to cache Facebook User Info with Facebook Login in IOS App

自作多情 提交于 2019-12-10 17:53:50

问题


I am integrating Facebook SDK 3.1 to my iOS 5 app. After Facebook Login, I have to query like this to get user info

NSString *query = @"SELECT uid, name, pic_big,username FROM user where uid = me()";

NSDictionary *queryParam =
[NSDictionary dictionaryWithObjectsAndKeys:query, @"q", nil];

[FBRequestConnection startWithGraphPath:@"/fql"
                             parameters:queryParam
                             HTTPMethod:@"GET"
                      completionHandler:^(FBRequestConnection *connection,
                                          id result,
                                          NSError *error) { ....

Now there are two issues with this approach:

1- User has just waited to get himself authenticated from Facebook and now just after that he has to wait again for to get his basic profile info to be fetched from web.

-Q- How can I fetch this info with the Facebook Login web call?

-2- When user reopens the app from login screen, if FBSession is still open and valid Facebok will re-authenticate that user but I would still have to get his basic
profile info from web...

-Q- How can I cache user's basic profile info in my app? Is there any id in FBSession object on which I could cache the user info?

Thanks in advance. Moeen.


回答1:


1- User has just waited to get himself authenticated from Facebook and now just after that he has to wait again for to get his basic profile info to be fetched from web.

-Q- How can I fetch this info with the Facebook Login web call ?

The original wait times should be minimal with proper usage. You cannot "append" an API call to a login request. Facebook used to have a preload_fql tool, but no longer supports that.

-2- When user reopens the app from login screen, if FBSession is still open and valid Facebok will re-authenticate that user but I would still have to get his basic profile info from web ...

-Q- How can I cache user's basic profile info in my app ? Is there any id in FBSession object on which I could cache the user info ?

This is a matter of your application design. My suggestion would to create a NSMutableDictionary as a class property, and call it cached_user_data or something. Save user data in there.



来源:https://stackoverflow.com/questions/13788061/how-to-cache-facebook-user-info-with-facebook-login-in-ios-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!