In my app, the signup with Facebook process flow goes like this:
signup with Facebook -> setup profile image and username -> home screen
…and the login with Facebook process flow goes like this:
login with Facebook -> home screen
However in the tutorial provided by Facebook, there's only 1 function which is login. how can I differentiate the process? I looked at the function documentation of
[FBSession openActiveSessionWithReadPermissions:allowLoginUI:completionHandler:]
It says that the function can run asynchronously (the login UI is not shown even when allowLoginUI
is set to YES, therefore the completionHandler
is called) or synchronously (the login UI is shown, and then redirect to my app, therefore calling the method - (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error
in the AppDelegate)
So, my question is, IF the method sessionStateChanged
is called by my signup function or login function, how can I differentiate them, so that I can navigate to appropriate screen?
I ended up using a flag, stored in NSUserDefault
. If the user click FBSignup, I set the flag to @"fbSignup"
else, if the user click FBLogin, I set the flag to @"fbLogin"
. On the method - (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error
I just check the flag whether it is @"fbSignup"
or @"fbLogin"