summaryrefslogtreecommitdiff
path: root/platform/ios/src/MGLMapboxEvents.m
diff options
context:
space:
mode:
authorRandall Lee <randall.lee@mapbox.com>2018-06-08 14:39:43 -0700
committerFabian Guerra <fabian.guerra@mapbox.com>2018-06-22 13:25:57 -0700
commita8dc9ede393a2d6118d35dafbffc16447389894d (patch)
tree456954ad4f03fc6b302446f8dc72526257612534 /platform/ios/src/MGLMapboxEvents.m
parent1642dd9b89c46ce01f62c40f3cd16c8999d0e508 (diff)
downloadqtlocation-mapboxgl-upstream/fabian-cp-12088.tar.gz
[ios] Add custom events library start-up delay (#12088)upstream/fabian-cp-12088
* [ios] Add custom delay Adds a custom delay to the events library initialization. This is only active when using certain profile configurations. * [ios] events library version update to v0.4.1 * Update Events Library to include missing MGL_EXPORT * Add MMEEventsService files to Events Lib Submodule * Change delayTime type to int64_t # Conflicts: # platform/ios/ios.xcodeproj/project.pbxproj # platform/ios/vendor/mapbox-events-ios
Diffstat (limited to 'platform/ios/src/MGLMapboxEvents.m')
-rw-r--r--platform/ios/src/MGLMapboxEvents.m38
1 files changed, 25 insertions, 13 deletions
diff --git a/platform/ios/src/MGLMapboxEvents.m b/platform/ios/src/MGLMapboxEvents.m
index 05f291d8a0..e9f27b3446 100644
--- a/platform/ios/src/MGLMapboxEvents.m
+++ b/platform/ios/src/MGLMapboxEvents.m
@@ -8,6 +8,8 @@ static NSString * const MGLMapboxMetricsEnabled = @"MGLMapboxMetricsEnabled";
static NSString * const MGLMapboxMetricsDebugLoggingEnabled = @"MGLMapboxMetricsDebugLoggingEnabled";
static NSString * const MGLTelemetryAccessToken = @"MGLTelemetryAccessToken";
static NSString * const MGLTelemetryBaseURL = @"MGLTelemetryBaseURL";
+static NSString * const MGLEventsProfile = @"MMEEventsProfile";
+static NSString * const MGLVariableGeofence = @"VariableGeofence";
@interface MGLMapboxEvents ()
@@ -122,21 +124,31 @@ static NSString * const MGLTelemetryBaseURL = @"MGLTelemetryBaseURL";
}
+ (void)setupWithAccessToken:(NSString *)accessToken {
- NSString *semanticVersion = [NSBundle mgl_frameworkInfoDictionary][@"MGLSemanticVersionString"];
- NSString *shortVersion = [NSBundle mgl_frameworkInfoDictionary][@"CFBundleShortVersionString"];
- NSString *sdkVersion = semanticVersion ?: shortVersion;
+ int64_t delayTime = 0;
- // It is possible that an alternative access token was already set on this instance when the class was loaded
- // Use it if it exists
- NSString *resolvedAccessToken = [MGLMapboxEvents sharedInstance].accessToken ?: accessToken;
-
- [[[self sharedInstance] eventsManager] initializeWithAccessToken:resolvedAccessToken userAgentBase:MGLAPIClientUserAgentBase hostSDKVersion:sdkVersion];
-
- // It is possible that an alternative base URL was set on this instance when the class was loaded
- // Use it if it exists
- if ([MGLMapboxEvents sharedInstance].baseURL) {
- [[MGLMapboxEvents sharedInstance] eventsManager].baseURL = [MGLMapboxEvents sharedInstance].baseURL;
+ if ([[[NSBundle mainBundle] objectForInfoDictionaryKey:MGLEventsProfile] isEqualToString:MGLVariableGeofence]) {
+ delayTime = 10;
}
+
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayTime * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ NSString *semanticVersion = [NSBundle mgl_frameworkInfoDictionary][@"MGLSemanticVersionString"];
+ NSString *shortVersion = [NSBundle mgl_frameworkInfoDictionary][@"CFBundleShortVersionString"];
+ NSString *sdkVersion = semanticVersion ?: shortVersion;
+
+ // It is possible that an alternative access token was already set on this instance when the class was loaded
+ // Use it if it exists
+ NSString *resolvedAccessToken = [MGLMapboxEvents sharedInstance].accessToken ?: accessToken;
+
+ [[[self sharedInstance] eventsManager] initializeWithAccessToken:resolvedAccessToken userAgentBase:MGLAPIClientUserAgentBase hostSDKVersion:sdkVersion];
+
+ // It is possible that an alternative base URL was set on this instance when the class was loaded
+ // Use it if it exists
+ if ([MGLMapboxEvents sharedInstance].baseURL) {
+ [[MGLMapboxEvents sharedInstance] eventsManager].baseURL = [MGLMapboxEvents sharedInstance].baseURL;
+ }
+
+ [self flush];
+ });
}
+ (void)pushTurnstileEvent {