From 6904be23da90e8b35b4a087ff92ed12780692069 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Fri, 3 Mar 2023 12:14:08 +0200 Subject: [PATCH] Fix push notification token registration race/missing (#7183) --- app/init/push_notifications.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/init/push_notifications.ts b/app/init/push_notifications.ts index 0f41efa76..ec37f9e89 100644 --- a/app/init/push_notifications.ts +++ b/app/init/push_notifications.ts @@ -37,22 +37,22 @@ class PushNotifications { configured = false; init(register: boolean) { - if (register) { - this.registerIfNeeded(); - } - Notifications.events().registerNotificationOpened(this.onNotificationOpened); Notifications.events().registerRemoteNotificationsRegistered(this.onRemoteNotificationsRegistered); Notifications.events().registerNotificationReceivedBackground(this.onNotificationReceivedBackground); Notifications.events().registerNotificationReceivedForeground(this.onNotificationReceivedForeground); + + if (register) { + this.registerIfNeeded(); + } } async registerIfNeeded() { const isRegistered = await Notifications.isRegisteredForRemoteNotifications(); if (!isRegistered) { await requestNotifications(['alert', 'sound', 'badge']); - Notifications.registerRemoteNotifications(); } + Notifications.registerRemoteNotifications(); } createReplyCategory = () => {