Skip to content

Commit 8fcccb4

Browse files
committed
[LP-11199] Fixing a crash when entering background
1 parent 0172e23 commit 8fcccb4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Leanplum-SDK/Classes/Internal/Leanplum.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#import "LPFileTransferManager.h"
5151
#import "LPRequestSender.h"
5252
#import "LPAPIConfig.h"
53+
#import "LPOperationQueue.h"
5354

5455
static NSString *leanplum_deviceId = nil;
5556
static NSString *registrationEmail = nil;
@@ -1180,13 +1181,16 @@ + (void)pause
11801181

11811182
// Block that finish task.
11821183
void (^finishTaskHandler)(void) = ^(){
1184+
// Make sure all database operations are done before ending the background task.
1185+
[[LPOperationQueue serialQueue] waitUntilAllOperationsAreFinished];
1186+
11831187
[application endBackgroundTask:backgroundTask];
11841188
backgroundTask = UIBackgroundTaskInvalid;
11851189
};
11861190

11871191
// Start background task to make sure it runs when the app is in background.
11881192
backgroundTask = [application beginBackgroundTaskWithExpirationHandler:finishTaskHandler];
1189-
1193+
11901194
// Send pause event.
11911195
LPRequestFactory *reqFactory = [[LPRequestFactory alloc]
11921196
initWithFeatureFlagManager:[LPFeatureFlagManager sharedManager]];

0 commit comments

Comments
 (0)