diff --git a/native/ios/Comm/AppDelegate.mm b/native/ios/Comm/AppDelegate.mm --- a/native/ios/Comm/AppDelegate.mm +++ b/native/ios/Comm/AppDelegate.mm @@ -168,6 +168,7 @@ [self attemptDatabaseInitialization]; comm::ThreadOperations::updateSQLiteUnreadStatus(threadID, false); } + dispatch_semaphore_t rescind_completed_sema = dispatch_semaphore_create(0); [[UNUserNotificationCenter currentNotificationCenter] getDeliveredNotificationsWithCompletionHandler:^( NSArray *notifications) { @@ -180,10 +181,10 @@ removeDeliveredNotificationsWithIdentifiers:identifiers]; } } - dispatch_async(dispatch_get_main_queue(), ^{ - completionHandler(UIBackgroundFetchResultNewData); - }); + dispatch_semaphore_signal(rescind_completed_sema); }]; + dispatch_semaphore_wait(rescind_completed_sema, DISPATCH_TIME_FOREVER); + completionHandler(UIBackgroundFetchResultNewData); return YES; } return NO;