diff options
author | Jesse Bounds <jesse@rebounds.net> | 2017-01-11 15:55:54 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-11 15:55:54 -0800 |
commit | 4332b3b9539e1c059b18c77ef6c0a9e6af44fe84 (patch) | |
tree | eae5ce52fe3e433107708ac2776a6f101346b197 /platform/ios/src/MGLAPIClient.m | |
parent | f1fc9bdfeb9ba107d27242ee4618228c204e98a3 (diff) | |
download | qtlocation-mapboxgl-4332b3b9539e1c059b18c77ef6c0a9e6af44fe84.tar.gz |
Flush telemetry cache when data collection is paused (#7672)
[ios] Flush telemetry cache when data collection is paused
This flushes the cache just before pausing so that data collected
before the pause is not thrown away. It also refactors event
creation to avoid possible nil value inserts into dictionaries
and adds a small optimization to avoid creating immutable
dictionaries to help create mutable ones.
Also:
- Remove cancel API in API client
The cancelAll API is not used. The array of data tasks it maintains
has proven problematic. This removes the API and the problematic
implementation. As safer version of it can be brought back if cancel
task functionality is required in the future.
- Remove unused battery method
Diffstat (limited to 'platform/ios/src/MGLAPIClient.m')
-rw-r--r-- | platform/ios/src/MGLAPIClient.m | 11 |
1 files changed, 0 insertions, 11 deletions
diff --git a/platform/ios/src/MGLAPIClient.m b/platform/ios/src/MGLAPIClient.m index 7fb6538e5d..5e8ee5fe1d 100644 --- a/platform/ios/src/MGLAPIClient.m +++ b/platform/ios/src/MGLAPIClient.m @@ -21,7 +21,6 @@ static NSString * const MGLAPIClientHTTPMethodPost = @"POST"; @property (nonatomic, copy) NSData *geoTrustCert; @property (nonatomic, copy) NSData *testServerCert; @property (nonatomic, copy) NSString *userAgent; -@property (nonatomic) NSMutableArray *dataTasks; @property (nonatomic) BOOL usesTestServer; @end @@ -33,7 +32,6 @@ static NSString * const MGLAPIClientHTTPMethodPost = @"POST"; if (self) { _session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:nil]; - _dataTasks = [NSMutableArray array]; [self loadCertificates]; [self setupBaseURL]; [self setupUserAgent]; @@ -59,24 +57,15 @@ static NSString * const MGLAPIClientHTTPMethodPost = @"POST"; error = error ?: statusError; completionHandler(error); } - [self.dataTasks removeObject:dataTask]; dataTask = nil; }]; [dataTask resume]; - if (dataTask) { - [self.dataTasks addObject:dataTask]; - } } - (void)postEvent:(nonnull MGLMapboxEventAttributes *)event completionHandler:(nullable void (^)(NSError * _Nullable error))completionHandler { [self postEvents:@[event] completionHandler:completionHandler]; } -- (void)cancelAll { - [self.dataTasks makeObjectsPerformSelector:@selector(cancel)]; - [self.dataTasks removeAllObjects]; -} - #pragma mark Utilities - (NSURLRequest *)requestForEvents:(NS_ARRAY_OF(MGLMapboxEventAttributes *) *)events { |