#1033 - Flush all events to server when app enters background
This commit is contained in:
@@ -21,4 +21,6 @@
|
||||
|
||||
- (void) pushEvent:(NSString *)event withAttributes:(NSDictionary *)attributeDictionary;
|
||||
|
||||
- (void) flush;
|
||||
|
||||
@end
|
||||
@@ -407,10 +407,6 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
|
||||
email = [NSString stringWithFormat:@"%i", sendMail];
|
||||
}
|
||||
[evt setValue:email forKey:@"enabled.email"];
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
return YES;
|
||||
@@ -590,6 +586,9 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
|
||||
|
||||
- (void)appDidBackground:(NSNotification *)notification
|
||||
{
|
||||
// Flush Any Events Still In Queue
|
||||
[[MGLMapboxEvents sharedManager] flush];
|
||||
|
||||
mbglMap->stop();
|
||||
|
||||
[self.glView deleteDrawable];
|
||||
|
||||
@@ -156,13 +156,17 @@ NSNumber *scale;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int upper = (int)_flushAt;
|
||||
if (_flushAt > [_queue count]) {
|
||||
NSLog(@"flush() flushAt (%lu) is greater than current queue count (%lu) so just return", _flushAt, [_queue count]);
|
||||
return;
|
||||
if ([_queue count] == 0) {
|
||||
return;
|
||||
}
|
||||
upper = (int)[_queue count];
|
||||
}
|
||||
|
||||
// Create Array of Events to push to the Server
|
||||
NSRange theRange = NSMakeRange(0, (int)_flushAt);
|
||||
NSRange theRange = NSMakeRange(0, upper);
|
||||
NSArray *events = [_queue subarrayWithRange:theRange];
|
||||
|
||||
// Update Queue to remove events sent to server
|
||||
|
||||
Reference in New Issue
Block a user