You have to create and show a FBLoginDialog to the user. The delegate method will not be called until the user has logged in. It has nothing to do with creating the session instance in the first place.
You have to create and show a FBLoginDialog to the user. The delegate method will not be called until the user has logged in.It has nothing to do with creating the session instance in the first place. How do I get a reference to a session object so I can connect to their Facebook account The Facebook Connect library will store the session info in your app's user defaults.
You don't have to do anything to store it.As I understand it, on every launch of your app you should create the session object with +sessionForApplication:secret:delegate: and then call session resume. If the FBConnect library finds a valid session stored in the user defaults, it will return YES and you can proceed as the user is now logged in. If resume returns NO, you will have to show the login dialog.
From Facebook's docs: The session information will be stored on the iPhone disk in your application's preferences, so you won't have to ask the user to log in every time they use your application. After you've created your session object, call session resume to resume a previous session. If the session has expired or you have yet to create a session, it will return NO and you will have to ask your user to log in.
Sessions expire after two hours of inactivity.
You said, "As I understand it, on every launch of your app you should create the session object with +sessionForApplication:secret:delegate: and then call session resume. " My question: is the valid session the return value from this method, or the session object that is passed to the delegate? If it's the former, why do I need a delegate?(Passing nil as the delegate causes it to crash.) And if it's the latter, what is the point of the returned session object?
Thanks. – Greg Maletic Feb 9 '10 at 7:49 Both are the same object and thus equally valid.It's customary for delegate methods to include the delegating object as a parameter so that the programmer can identify which object the delegate message is about. As to your question, "why do I need a delegate?
": Because creating a session is not the same as logging in.As I said, after creating the session object, you need to call the FBLoginDialog and then FBSession will use the delegate method to inform you when the user has actually logged in. At that point, you can continue using the session. – Ole Begemann Feb 9 '10 at 11:39 Thanks...but what if I know the user has already logged in?
I shouldn't need to show a log in dialog then. I don't want to have that Facebook dialog popping up every time (if I call FBDialog, if the user is already logged in, it pops open, then closes, which is distracting. ) – Greg Maletic Feb 9 '10 at 17:57 I have already talked about that in my answer.
– Ole Begemann Feb 9 '10 at 18:00.
This is really following on from Ole's answer and comments as it is all in there. This is what I did. Firstly create the session object: facebookSession = FBSession sessionForApplication:SESSION secret:SECRET delegate:selfretain; facebookSession resume; The second line pulls the session data from the settings file to keep you logged on if the user specifies that they'd like to be kept logged on.
You have to implement the method: - (void)session:(FBSession*)session didLogin:(FBUID)uid although I don't use it for anything. To check if the user is already logged on, I call: FBSession session isConnected and then either display the login dialog or straight to the publish dialog if they are already logged on.
This is really following on from Ole's answer and comments as it is all in there. This is what I did.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.