Merge pull request #1347 from mapbox/1345-ua-build-number
Build Number To User Agent
This commit is contained in:
@@ -32,6 +32,7 @@ extern NSString *const MGLEventGestureRotateStart;
|
||||
+ (void) setToken:(NSString *)token;
|
||||
+ (void) setAppName:(NSString *)appName;
|
||||
+ (void) setAppVersion:(NSString *)appVersion;
|
||||
+ (void) setAppBuildNumber:(NSString *)appBuildNumber;
|
||||
+ (void) pauseMetricsCollection;
|
||||
+ (void) resumeMetricsCollection;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<key>CFBundleSignature</key>
|
||||
<string>MBGL</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.0.2</string>
|
||||
<string>0.0.3</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
@@ -223,8 +223,10 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
|
||||
// metrics: initial setup
|
||||
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
|
||||
NSString *appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
||||
NSString *appBuildNumber = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
|
||||
if (appName != nil) [MGLMapboxEvents setAppName:appName];
|
||||
if (appVersion != nil) [MGLMapboxEvents setAppVersion:appVersion];
|
||||
if (appBuildNumber != nil) [MGLMapboxEvents setAppBuildNumber:appBuildNumber];
|
||||
|
||||
// create GL view
|
||||
//
|
||||
|
||||
@@ -62,6 +62,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
|
||||
@property (atomic) NSString *token;
|
||||
@property (atomic) NSString *appName;
|
||||
@property (atomic) NSString *appVersion;
|
||||
@property (atomic) NSString *appBuildNumber;
|
||||
@property (atomic) NSString *instanceID;
|
||||
@property (atomic) NSString *advertiserId;
|
||||
@property (atomic) NSString *vendorId;
|
||||
@@ -247,6 +248,13 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
|
||||
[MGLMapboxEvents sharedManager].appVersion = appVersion;
|
||||
}
|
||||
|
||||
// Must be called from the main thread.
|
||||
//
|
||||
+ (void) setAppBuildNumber:(NSString *)appBuildNumber {
|
||||
assert([[NSThread currentThread] isMainThread]);
|
||||
[MGLMapboxEvents sharedManager].appBuildNumber = appBuildNumber;
|
||||
}
|
||||
|
||||
// Must be called from the main thread.
|
||||
//
|
||||
+ (void) pauseMetricsCollection {
|
||||
@@ -455,8 +463,8 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
|
||||
// Can be called from any thread.
|
||||
//
|
||||
- (NSString *) getUserAgent {
|
||||
if (self.appName != nil && self.appVersion != nil && ([self.userAgent rangeOfString:self.appName].location == NSNotFound)) {
|
||||
self.userAgent = [NSString stringWithFormat:@"%@/%@ %@", self.appName, self.appVersion, self.userAgent];
|
||||
if (self.appName != nil && self.appVersion != nil && self.appBuildNumber != nil && ([self.userAgent rangeOfString:self.appName].location == NSNotFound)) {
|
||||
self.userAgent = [NSString stringWithFormat:@"%@/%@-%@ %@", self.appName, self.appVersion, self.appBuildNumber, self.userAgent];
|
||||
}
|
||||
return self.userAgent;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user