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 08:39:02 -0800 |
commit | 860138dd384b899224742c1cb074aee3171062da (patch) | |
tree | 6eb330ec459fb818d8bd5ca6b49b05c5d0e85440 /platform | |
parent | 78901ee7120327f2dc004ad3d5dbf0bc1f81f734 (diff) | |
download | qtlocation-mapboxgl-860138dd384b899224742c1cb074aee3171062da.tar.gz |
record app fg/bg/inactive state in telemetry
Diffstat (limited to 'platform')
-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 7f8df61095..259cfb3def 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; |