diff options
author | Justin R. Miller <incanus@codesorcery.net> | 2015-12-03 14:48:15 -0800 |
---|---|---|
committer | Justin R. Miller <incanus@codesorcery.net> | 2015-12-04 21:46:38 -0800 |
commit | 61180c9ea570b4b6728f993480fc6f2a92c214c6 (patch) | |
tree | dda39a130938191a73e3b7e4417f50f8902b2f31 | |
parent | a3021731bd4f84845e89ce71b3dd6466d45f5e08 (diff) |
record app fg/bg/inactive state in telemetry
-rw-r--r-- | platform/ios/MGLMapboxEvents.m | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 7f8df6109..259cfb3de 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -495,7 +495,9 @@ const NSTimeInterval MGLFlushInterval = 60; MGLReachability *reachability = [MGLReachability reachabilityForLocalWiFi]; [evt setValue:([reachability isReachableViaWiFi] ? @YES : @NO) forKey:@"wifi"]; - + + [evt setValue:[strongSelf applicationState] forKey:@"applicationState"]; + [evt setValue:@([strongSelf contentSizeScale]) forKey:@"accessibilityFontScale"]; // Make Immutable Version @@ -655,6 +657,41 @@ const NSTimeInterval MGLFlushInterval = 60; // Can be called from any thread. // +- (NSString *) applicationState { + __block NSString *result; + + NSString *(^applicationStateBlock)(void) = ^{ + switch ([UIApplication sharedApplication].applicationState) { + case UIApplicationStateActive: + result = @"Active"; + break; + case UIApplicationStateInactive: + result = @"Inactive"; + break; + case UIApplicationStateBackground: + result = @"Background"; + break; + default: + result = @"Default - Unknown"; + break; + } + + return result; + }; + + if ( ! [[NSThread currentThread] isMainThread]) { + dispatch_sync(dispatch_get_main_queue(), ^{ + result = applicationStateBlock(); + }); + } else { + result = applicationStateBlock(); + } + + return result; +} + +// Can be called from any thread. +// - (NSInteger) contentSizeScale { __block NSInteger result = -9999; |