Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
}
like image 571
Old McStopher Avatar asked Dec 16 '11 16:12

Old McStopher


2 Answers

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.

like image 68
Saurabh Passolia Avatar answered Nov 19 '22 11:11

Saurabh Passolia


I was real curious about this too. I looked at my inherited code for my app and didn't see any flurry activity in didbecomeactive, foreground, etc. I only saw the startsession in didfinishlaunchingwithoptions. I saw the below on the flurry site re: startsession, but i still don't get how it works, just behind the scenes stuff the flurry library does? @samfisher, can you elaborate?

"This method serves as the entry point to Flurry Analytics collection. It must be called in the scope of applicationDidFinishLaunching. The session will continue for the period the app is in the foreground until your app is backgrounded for the time specified in setSessionContinueSeconds:. If the app is resumed in that period the session will continue, otherwise a new session will begin."

FlurryApi.h shows the default as 10 for setSessionContinueSeconds so I guess Flurry handles it, I'm just looking for more confirmation.

http://support.flurry.com/sdkdocs/iOS/interface_flurry_analytics.html#a78b0b92085b38875d51f1ca0d699849a

like image 33
skinsfan00atg Avatar answered Nov 19 '22 11:11

skinsfan00atg