I have implemented Facebook in my application, and noticed that I have some problems which I just can’t figure out.
When Facebook signle-signon returns to my application after approval in Facebook.app, while running and debugging from XCode.. the app kind-of hang when resuming and after about 30 – 40 seconds it switches back to the page that requested facebook authentication.
When I run the app stand-alone, without debugging in XCode the app crashes after 10 – 15 seconds. I pulled the crash log from the device, and this is the result: http://pastebin.com/MeT7Rt52
When I test this in the simulator, the same things happens… allthough it uses Safari instead. I do not believe that Facebook or Safari is or could be the source of the problem… since it cannot be.
I have searched and searched, but cannot find an answer to this problem.
Here is some of my code in my AooDelegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
[FlurryAnalytics startSession:APP_FLURRY];
[TestFlight takeOff:APP_TESTFLIGHT_KEY];
facebook = [[Facebook alloc] initWithAppId:APP_FB_APP_ID andDelegate:self];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window setBackgroundColor:[UIColor scrollViewTexturedBackgroundColor]];
[...]
return YES;
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [facebook handleOpenURL:url];
}
- (void)fbDidLogin {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
}
I isolated the problem, and the answer to the question is something that I didn’t expect it to be.
In my application, I use TestFlightApp‘s API. I initiate it when the application is launched, as I should… however, this is also the thing that prevents the app from returning to its previous state (as it seems).
I dissabled TestFligthApp and the application resumed as it should.
Thank you for your answers!