From b57e237b142ee6c74c02f5e22a1c6e2b4f2d0be8 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Sat, 9 Jan 2016 14:22:39 -0500 Subject: [PATCH] [ios] send turnstile event when telemetry is paused --- platform/ios/src/MGLMapboxEvents.m | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/platform/ios/src/MGLMapboxEvents.m b/platform/ios/src/MGLMapboxEvents.m index 5fc062a2a..8490c0319 100644 --- a/platform/ios/src/MGLMapboxEvents.m +++ b/platform/ios/src/MGLMapboxEvents.m @@ -543,7 +543,19 @@ const NSTimeInterval MGLFlushInterval = 60; [request setHTTPBody:jsonData]; // Send non blocking HTTP Request to server - [[_session dataTaskWithRequest:request] resume]; + if ( ! strongSelf.paused) { + [[strongSelf.session dataTaskWithRequest:request] resume]; + } else { + for (MGLMapboxEventAttributes *event in events) { + if ([event[@"event"] isEqualToString:MGLEventTypeAppUserTurnstile]) { + NSURLSession *temporarySession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] + delegate:strongSelf + delegateQueue:nil]; + [[temporarySession dataTaskWithRequest:request] resume]; + [temporarySession finishTasksAndInvalidate]; + } + } + } } }); } @@ -880,7 +892,7 @@ const NSTimeInterval MGLFlushInterval = 60; completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); } } - + } @end