From f54f5e94a4087e90d16d8ba2df69629140656e1d Mon Sep 17 00:00:00 2001 From: Pengyu Chen Date: Thu, 19 Oct 2023 22:42:36 -0400 Subject: [PATCH] Fix iOS notification crash issue --- lib/ios/RNNotificationEventHandler.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ios/RNNotificationEventHandler.m b/lib/ios/RNNotificationEventHandler.m index db5e7fe4c..c4793e484 100644 --- a/lib/ios/RNNotificationEventHandler.m +++ b/lib/ios/RNNotificationEventHandler.m @@ -29,8 +29,14 @@ - (void)didReceiveForegroundNotification:(UNNotification *)notification withComp } - (void)didReceiveNotificationResponse:(UNNotificationResponse *)response completionHandler:(void (^)(void))completionHandler { - [_store setActionCompletionHandler:completionHandler withCompletionKey:response.notification.request.identifier]; + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + [self->_store setActionCompletionHandler:^{ + dispatch_async(dispatch_get_main_queue(), ^{ + completionHandler(); + }); + } withCompletionKey:response.notification.request.identifier]; [RNEventEmitter sendEvent:RNNotificationOpened body:[RNNotificationParser parseNotificationResponse:response]]; + }); } @end