Skip to content

Commit 3633a05

Browse files
Moses DeJongfacebook-github-bot
Moses DeJong
authored andcommitted
Invoke registerForRemoteNotifications on main UI thread to avoid error messages in Xcode
Summary: Invoke registerForRemoteNotifications on main UI thread to avoid error messages in Xcode. Changelog: [iOS][Fixed] - Invoke registerForRemoteNotifications on main UI thread. Reviewed By: philIip Differential Revision: D33780141 fbshipit-source-id: 64b825dfc15e7ac262e210b90bb334a7e415e402
1 parent be260b9 commit 3633a05

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Libraries/PushNotificationIOS/RCTPushNotificationManager.mm

+6-4
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,12 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
313313
if (error != NULL) {
314314
reject(@"-1", @"Error - Push authorization request failed.", error);
315315
} else {
316-
[RCTSharedApplication() registerForRemoteNotifications];
317-
[UNUserNotificationCenter.currentNotificationCenter getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
318-
resolve(RCTPromiseResolveValueForUNNotificationSettings(settings));
319-
}];
316+
dispatch_async(dispatch_get_main_queue(), ^{
317+
[RCTSharedApplication() registerForRemoteNotifications];
318+
[UNUserNotificationCenter.currentNotificationCenter getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
319+
resolve(RCTPromiseResolveValueForUNNotificationSettings(settings));
320+
}];
321+
});
320322
}
321323
}];
322324
}

0 commit comments

Comments
 (0)