Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit c03fb18

Browse files
registerForPushNotifications() resolving instantly #1277
1 parent a882277 commit c03fb18

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/messaging/messaging.ios.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,13 @@ export function addBackgroundRemoteNotificationHandler(appDelegate) {
177177
};
178178

179179
appDelegate.prototype.applicationDidFailToRegisterForRemoteNotificationsWithError = (application: UIApplication, error: NSError) => {
180-
_rejectWhenDidFailToRegisterForNotifications && _rejectWhenDidFailToRegisterForNotifications(error.localizedDescription);
180+
if (error.localizedDescription.indexOf("not supported in the simulator") > -1) {
181+
// Why? See https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/1277
182+
// Note that this method will also be invoked on a simulator when the consent popup is declined
183+
_resolveWhenDidRegisterForNotifications && _resolveWhenDidRegisterForNotifications();
184+
} else {
185+
_rejectWhenDidFailToRegisterForNotifications && _rejectWhenDidFailToRegisterForNotifications(error.localizedDescription);
186+
}
181187
};
182188

183189
appDelegate.prototype.applicationDidReceiveRemoteNotificationFetchCompletionHandler = (app, notification, completionHandler) => {

0 commit comments

Comments
 (0)