diff --git a/src/core/features/pushnotifications/services/push-delegate.ts b/src/core/features/pushnotifications/services/push-delegate.ts index 5b519744f..af24f47c9 100644 --- a/src/core/features/pushnotifications/services/push-delegate.ts +++ b/src/core/features/pushnotifications/services/push-delegate.ts @@ -108,7 +108,7 @@ export class CorePushNotificationsDelegateService { handlers = handlers.sort((a, b) => (a.priority || 0) <= (b.priority || 0) ? 1 : -1); // Execute the first one. - handlers[0]?.handleClick(notification); + await handlers[0]?.handleClick(notification); } /** diff --git a/src/core/features/pushnotifications/services/pushnotifications.ts b/src/core/features/pushnotifications/services/pushnotifications.ts index f8bb9cfb3..92b8b21ef 100644 --- a/src/core/features/pushnotifications/services/pushnotifications.ts +++ b/src/core/features/pushnotifications/services/pushnotifications.ts @@ -54,6 +54,8 @@ import { CorePlatform } from '@services/platform'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreSiteInfo } from '@classes/sites/unauthenticated-site'; import { Push } from '@features/native/plugins'; +import { CoreNavigator } from '@services/navigator'; +import { CoreWait } from '@singletons/wait'; /** * Service to handle push notifications. @@ -442,7 +444,26 @@ export class CorePushNotificationsProvider { async notificationClicked(data: CorePushNotificationsNotificationBasicData): Promise { await ApplicationInit.donePromise; - CorePushNotificationsDelegate.clicked(data); + if (CoreSites.isLoggedIn()) { + CoreSites.runAfterLoginNavigation({ + priority: 600, + callback: async () => { + await CorePushNotificationsDelegate.clicked(data); + }, + }); + + return; + } + + // User not logged in, wait for the path to be a "valid" path (not a parent path used when starting the app). + await CoreWait.waitFor(() => { + const currentPath = CoreNavigator.getCurrentPath(); + + return currentPath !== '/' && currentPath !== '/login'; + }, { timeout: 400 }); + + await CorePushNotificationsDelegate.clicked(data); + } /**