Take the 2-minute tour ×

I have implemented FBConnect into my iPhone App, and it works perfectly on the Simulator (v4.3). However, when I test the the same code on my iPhone (v4.3.3), it appears as though my Facebook Button now exits out of my application and opens the Facebook App. The Facebook App displays a page saying I have already authorized my app, and that I should press "Okay" to continue. At first I did not think this was necessarily indicative of a problem, but when I hit the Okay button, I am simply returned to my appViewController where I clicked on my Facebook Button in the beginning.

What I expected, and what occurs correctly in my simulator, is that a smaller Facebook subview window would appear in my application view after clicking the Facebook Button, and I would be given the option to publish to my Facebook Wall.

I should mention, that I have successfully been able to run the "DemoApp" (facebook-ios-sdk test program) on my iPhone. Also, my app does not crash and no errors are reported in my debugger console window.

Why am I experiencing such different results when running the application on my iPhone? Has anyone else experienced a similar problem? What can I do to fix it?

Thanks in advance, Jeremy

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Have you had a look at the "Authentication and Authorization" section at https://github.com/facebook/facebook-ios-sdk?

The difference between the simulator and your device is that your device has the Facebook app installed. If you didn't have the app installed, I'm guessing it would work perfectly because the authorization callbacks are handled directly within the app. However, with the Facebook app installed, after the user authenticates your app, the Facebook app "redirects" to your app using a URL handler.

It is your job to implement the correct URL handling code by setting up your plist property (which you appear to have done since your app relaunches after the Facebook app authorizes you), and also to respond correctly to the - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url app delegate message. The details to implement this launch handler correctly should be listed in the link above.

share|improve this answer
You are correct that if I uninstall the Facebook app from my device, that the program works as it did on the simulator. I also initially forgot about the URL handling method you mentioned above. However, after implementing the method in my Application's Delegate (see below), I still experience the same results (on sim and device)... What else could I be overlooking? I doubt this makes a difference, but I do have my facebook button as part of a Navigation Bar on a Flipside View. –  JRoss Jun 1 '11 at 16:36
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { return [[flipsideViewController facebook] handleOpenURL:url]; } –  JRoss Jun 1 '11 at 16:37
I am new to StackOverflow, and forgot to include your username so you would be notified. Thanks again for your help! –  JRoss Jun 1 '11 at 16:44
I have asked a follow-up question after approving your answer: handleOpenURL Method Not Called –  JRoss Jun 2 '11 at 15:43
add comment

Your Answer


