Here’s the test process I went through. A lot of writing, but I thought I’d go through the code and the test cases to better understand the issue I have. The CASE 3 is the one that caused the Error 400. Is this normal? Is there a way to trap this type of error?
Please note, step 7 of CASE 3 indicates after crashing/killing the app, the FB related code works like a charm.
Not sure if this is of any help, but maybe it would help identify where the problems are?
Also, I really wish I don’t have to call facebook.logout() like I need to. I mean, once logged in, I’d rather not to bring up permission screen and keep asking the user to okay it.
Anyhow, here it goes:
CASE 1: SUCCESS (with a freshly wiped device with a new user)
1 (scene A): facebook.login( myAppID, myFBListener, { “email” } )
* FB Connect button brings up FB log in screen
* User enters FB email address and FB password
* FB permission screen with email as part of the app requirement shows up
* User taps on Log in button
* Login process completes without a hitch and automatically triggers facebook.request( “me” ) in step 2
2 (scene A): facebook.request( “me” )
* Fetches login credential perfectly
* Saves login credential for the app
* Completes the scene A
3 (scene B): facebook.login( myAppID, myFBListener )
* This scene has FB Friend button
* Tapping on FB Friend button brings up FB permission screen (stating that the user has already authorized this app)
* User okays it, which automatically triggers the facebook.request( “me/friends” ) in step 4
4 (scene B): facebook.request( “me/friends” )
* Fetches friends list perfectly fine
* Loads the list of friends without a hitch
* Call facebook.logout()
Note: Without calling the facebook.logout() in key spot, moving on to the next step would trigger the “The operation couldn’t be completed. (com.facebook.sdk error 5.)” At least that’s what I remember happening. So I’ve kept facebook.logout() function in scene B everywhere it seems to need.
5 (scene B): facebook.login( myAppID, myPostListener, { “publish_actions” } )
* Each FB friend that was fetched in step 4 becomes a friend button
* Tapping on a friend button brings up FB permission screen (stating that the user has already authorized this app)
* User okays it
* automatically triggers facebook.showDialog( “feed”, attachment ) in step 6
6 (scene B): facebook.showDialog( “feed”, attachment )
* FB dialog pops up
* Tapping on Share button on FB dialog makes the post successfully
* Tapping on another friend’s button brings up FB dialog (without permission screen this time)
* All is good.
CASE 2: SUCCESS (with a freshly wiped device with a new user)
1 (scene A): facebook.login( myAppID, myFBListener, { “email” } )
* User skips the FB Connect button
2 (scene B): facebook.login( myAppID, myFBListener, { “email” } )
* This scene has FB Connect button this time (instead of FB Friend button).
* FB Connect button brings up FB Log in screen
* User enters FB email address and FB password
* FB permission screen with email as part of the app requirement come up
* User taps on Log in button
* Login process completes without a hitch and automatically triggers facebook.request( “me” ) in step 3
3 (scene B): facebook.request( “me” )
* Fetches login credential perfectly
* Call facebook.logout()
* Saves login credential for the app
* Upon successful save, automatically triggers facebook.login( myAppID, myFBListener ) in step 4
4 (scene B): facebook.login( myAppID, myFBListener )
* Immediately after the login process completes, FB permission screen comes up (stating that the user has already authorized this app)
* User okays it, which triggers facebook.request( “me/friends” ) in step 5
5 (scene B): facebook.request( “me/friends” )
* Fetches friends list perfectly fine.
* Loads the list of friends without a hitch
* Call facebook.logout()
6 (scene B): facebook.login( myAppID, myPostListener, { “publish_actions” } )
* Each FB friend that was fetched in step 5 becomes a friend button
* Tapping on a friend button brings up FB permission screen again (stating that the user has already authorized this app)
* User okays it, which automatically triggers facebook.showDialog( “feed”, attachment ) in step 7
7 (scene B): facebook.showDialog( “feed”, attachment )
* FB dialog pops up
* Tapping on Share button on FB dialog makes the post successfully
* Tapping on another friend’s button brings up FB dialog (without permission screen this time)
* All is good.
CASE 3: FAIL (with a freshly wiped device with a new user)
1 (scene A): facebook.login( myAppID, myFBListener, { “email” } )
* User skips FB Connect button
2 (scene B): facebook.login( myAppID, myFBListener, { “email” } )
* This scene has FB Connect button this time (instead of FB Friend button).
* FB Connect button brings up FB Log in screen
* User enters FB email address and FB password
* User closes the FB Log in screen (canceling the process)
* User is sent back to the scene with FB Connect button
* User taps on FB Connect button, which brings up FB Log in screen
* User enters FB email address and FB password and proceed to log in
* FB permission screen with email as part of the app requirement come up
* User closes the FB permission screen without tapping on Login button (canceling the process)
* User is sent back to the scene with FB Connect button
* User taps on FB Connect button again
* This time, user chooses to go through FB login process, which automatically triggers facebook.request( “me” ) in step 3
3 (scene B): facebook.request( “me” )
* Fetches login credential perfectly
* Call facebook.logout()
* Saves login credential for the app
* Upon successful save, automatically triggers facebook.login( myAppID, myFBListener ) in step 4
4 (scene B): facebook.login( myAppID, myFBListener )
* FB permission screen comes up (stating that the user has already authorized this app)
* User okays it, which triggers facebook.request( “me/friends” ) in step 5
5 (scene B): facebook.request( “me/friends” )
* FB permission screen comes up (stating that the user has already authorized this app)
* User closes the screen without tapping on okay
* It sends the user back to scene B with FB Connect button
6 (scene B): facebook.login( myAppID, myFBListener )
* User taps on FB Connect button again, which brings up FB permission screen again (stating that the user has already authorized this app)
* User taps on okay to the FB permission screen
* App crashes with Error: HTTP status code: 400
After restarting the app, I come back to Scene B straight away.
7 (Scene B): facebook.login( myAppID, myFBListener )
* This scene has FB Friend button this time (instead of FB Connect button). ( Edit: copy & paste caused mis-information. Here, the button now shows FB Friend. I’ve corrected it.)
* Tapping on FB Friend button appears to automatically okay FB permission and fetch FB friends list, which is equivalent to reaching the step 6 of case 2 without any interruption as far as the user experience is concerned. (And this is the type of user experience I’d like to offer after the user logs in to FB and authorizes the app just once.) [import]uid: 67217 topic_id: 34416 reply_id: 140299[/import]