From a8dc9ede393a2d6118d35dafbffc16447389894d Mon Sep 17 00:00:00 2001 From: Randall Lee Date: Fri, 8 Jun 2018 14:39:43 -0700 Subject: [ios] Add custom events library start-up delay (#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 --- platform/ios/src/MGLMapboxEvents.m | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'platform/ios/src/MGLMapboxEvents.m') 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 { -- cgit v1.2.1