Skip to content

Commit

Permalink
Invoke registerForRemoteNotifications on main UI thread to avoid erro…
Browse files Browse the repository at this point in the history
…r 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
  • Loading branch information
Moses DeJong authored and facebook-github-bot committed Feb 5, 2022
1 parent be260b9 commit 3633a05
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Libraries/PushNotificationIOS/RCTPushNotificationManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,12 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
if (error != NULL) {
reject(@"-1", @"Error - Push authorization request failed.", error);
} else {
[RCTSharedApplication() registerForRemoteNotifications];
[UNUserNotificationCenter.currentNotificationCenter getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
resolve(RCTPromiseResolveValueForUNNotificationSettings(settings));
}];
dispatch_async(dispatch_get_main_queue(), ^{
[RCTSharedApplication() registerForRemoteNotifications];
[UNUserNotificationCenter.currentNotificationCenter getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
resolve(RCTPromiseResolveValueForUNNotificationSettings(settings));
}];
});
}
}];
}
Expand Down

0 comments on commit 3633a05

Please sign in to comment.