Created
May 22, 2014 20:22
-
-
Save randydailey/349e550ba09e25fe4008 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // GSAppDelegate.m | |
| // ProximiT | |
| // | |
| // Created by Randy Dailey on 5/30/13. | |
| // Copyright (c) 2013 JLRD. All rights reserved. | |
| // | |
| @implementation GSAppDelegate | |
| - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
| { | |
| [GSAnalyticsProvider startSession:launchOptions]; | |
| return YES; | |
| } | |
| - (void)applicationWillEnterForeground:(UIApplication *)application | |
| { | |
| [GSAnalyticsProvider resume]; | |
| } | |
| - (void)applicationDidEnterBackground:(UIApplication *)application | |
| { | |
| [GSAnalyticsProvider close]; | |
| } | |
| - (void)applicationWillTerminate:(UIApplication *)application | |
| { | |
| [GSAnalyticsProvider terminate]; | |
| } | |
| @end | |
| @implementation GSAnalyticsProvider | |
| + (void)startSession:(NSDictionary *)launchOptions | |
| { | |
| // Enumerate all of the 'background' modes that can launch the app in this block | |
| if (launchOptions[UIApplicationLaunchOptionsLocationKey]) | |
| { | |
| [GSAnalyticsProvider setDimension:kDimensionSessionType value:@"Background"]; | |
| } | |
| else | |
| { | |
| [GSAnalyticsProvider setDimension:kDimensionSessionType value:@"Foreground"]; | |
| } | |
| // Open the session | |
| [[LocalyticsSession shared] open]; | |
| } | |
| + (void)resume | |
| { | |
| // Close any "Background session" | |
| [[LocalyticsSession shared] setLocation:[GSLocationManager shared].currentLocation.coordinate]; | |
| [[LocalyticsSession shared] close]; | |
| // Open a foreground session | |
| [GSAnalyticsProvider setDimension:kDimensionSessionType value:@"Foreground"]; | |
| [[LocalyticsSession shared] open]; | |
| [[LocalyticsSession shared] upload]; | |
| } | |
| + (void)close | |
| { | |
| // Close the foreground session | |
| [[LocalyticsSession shared] setLocation:[GSLocationManager shared].currentLocation.coordinate]; | |
| [[LocalyticsSession shared] close]; | |
| // Open the "Background Session" | |
| [GSAnalyticsProvider setDimension:kDimensionSessionType value:@"Background"]; | |
| [[LocalyticsSession shared] open]; | |
| [[LocalyticsSession shared] upload]; | |
| } | |
| + (void)terminate | |
| { | |
| // Close the foreground session | |
| [[LocalyticsSession shared] setLocation:[GSLocationManager shared].currentLocation.coordinate]; | |
| [[LocalyticsSession shared] close]; | |
| [[LocalyticsSession shared] upload]; | |
| } | |
| + (void)setDimension:(int)dimension value:(NSString *)value | |
| { | |
| [[LocalyticsSession shared] setCustomDimension:dimension value:value]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment