diff --git a/platform/ios/src/MGLMapboxEvents.m b/platform/ios/src/MGLMapboxEvents.m index 5fc062a2a2e..8490c031953 100644 --- a/platform/ios/src/MGLMapboxEvents.m +++ b/platform/ios/src/MGLMapboxEvents.m @@ -543,7 +543,19 @@ - (void) postEvents:(NS_ARRAY_OF(MGLMapboxEventAttributes *) *)events { [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 @@ - (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticat completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); } } - + } @end