Search code examples
iphoneioscocoa-touchuiapplicationdelegateflurry

Proper appDelegate method for Flurry startsession?


Flurry docs recommend placing the startSession call in applicationDidFinishLaunching:.

Two problems with this...

- (void)applicationDidFinishLaunching:(UIApplication *)application 
{
    [FlurryAnalytics startSession:@"AWESOMEAPIKEY"];

    // ...
}

1) Isn't application:didFinishLaunchingWithOptions: the new approved launch point?

2) This is only called once on launch, but don't we want session info every time a user opens or switches back to the app? Or does Flurry handle all that on their own by listening to some event or NSNotification?


Wouldn't a better place to put the startSession call be in applicationDidBecomeActive: or applicationWillEnterForeground:, like so?

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // ... Flurry AppCircle setup
    [FlurryAnalytics startSession:@"AWESOMEAPIKEY"];

    // ... your setup
}

Solution

  • for your case 1) correct place to put [FlurryAnalytics startSession:@"SOMESESSIONKEY"]; is

    application:didFinishLaunchingWithOptions:
    

    you can place it there without worries. I have done this by myself and the app is working awesome at appstore and providing the stats perfectly.

    for case 2), your secession will be automatically resumed when app returns to foreground so you dont have to do any special handling here.