diff options
author | Alex Zolotarev <alex@maps.me> | 2015-05-26 14:41:03 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:49:15 +0300 |
commit | 962140040ce99936d0346d60c8065aca0edc06c7 (patch) | |
tree | 5be72d131dda3cfcfe680cfcd6497678549f0e18 /3party/Alohalytics/src/apple/alohalytics_objc.mm | |
parent | 9d19ff9158f652bd2cf030e098c3d2287814b917 (diff) |
[ios][alohalytics] Use browser User-Agent for statistics.
Diffstat (limited to '3party/Alohalytics/src/apple/alohalytics_objc.mm')
-rw-r--r-- | 3party/Alohalytics/src/apple/alohalytics_objc.mm | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/3party/Alohalytics/src/apple/alohalytics_objc.mm b/3party/Alohalytics/src/apple/alohalytics_objc.mm index 4ee686d0ca..cb6e7f819a 100644 --- a/3party/Alohalytics/src/apple/alohalytics_objc.mm +++ b/3party/Alohalytics/src/apple/alohalytics_objc.mm @@ -41,7 +41,10 @@ SOFTWARE. #import <UIKit/UIDevice.h> #import <UIKit/UIScreen.h> #import <UIKit/UIApplication.h> +#import <UiKit/UIWebView.h> #import <AdSupport/ASIdentifierManager.h> +// Export user agent for HTTP module. +NSString * gBrowserUserAgent = nil; #endif // TARGET_OS_IPHONE using namespace alohalytics; @@ -287,8 +290,11 @@ static UIBackgroundTaskIdentifier sBackgroundTaskId = UIBackgroundTaskInvalid; } + (void)setup:(NSString *)serverUrl andFirstLaunch:(BOOL)isFirstLaunch withLaunchOptions:(NSDictionary *)options { - #if (TARGET_OS_IPHONE > 0) + // Initialize User Agent later, as it takes significant time at startup. + dispatch_async(dispatch_get_main_queue(), ^(void) { + gBrowserUserAgent = [[[UIWebView alloc] initWithFrame:CGRectZero] stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"]; + }); // Subscribe to basic app lifecycle events. sBackgroundThreadQueue = ::dispatch_queue_create([serverUrl UTF8String], DISPATCH_QUEUE_SERIAL); NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; |