Skip to content

Commit 0e6058a

Browse files
committed
MOBILE-4359 pushnotifications: Fix open push when app is dead
1 parent 2c25086 commit 0e6058a

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/core/features/pushnotifications/services/push-delegate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class CorePushNotificationsDelegateService {
108108
handlers = handlers.sort((a, b) => (a.priority || 0) <= (b.priority || 0) ? 1 : -1);
109109

110110
// Execute the first one.
111-
handlers[0]?.handleClick(notification);
111+
await handlers[0]?.handleClick(notification);
112112
}
113113

114114
/**

src/core/features/pushnotifications/services/pushnotifications.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ import { CorePlatform } from '@services/platform';
5454
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
5555
import { CoreSiteInfo } from '@classes/sites/unauthenticated-site';
5656
import { Push } from '@features/native/plugins';
57+
import { CoreNavigator } from '@services/navigator';
58+
import { CoreWait } from '@singletons/wait';
5759

5860
/**
5961
* Service to handle push notifications.
@@ -442,7 +444,26 @@ export class CorePushNotificationsProvider {
442444
async notificationClicked(data: CorePushNotificationsNotificationBasicData): Promise<void> {
443445
await ApplicationInit.donePromise;
444446

445-
CorePushNotificationsDelegate.clicked(data);
447+
if (CoreSites.isLoggedIn()) {
448+
CoreSites.runAfterLoginNavigation({
449+
priority: 600,
450+
callback: async () => {
451+
await CorePushNotificationsDelegate.clicked(data);
452+
},
453+
});
454+
455+
return;
456+
}
457+
458+
// User not logged in, wait for the path to be a "valid" path (not a parent path used when starting the app).
459+
await CoreWait.waitFor(() => {
460+
const currentPath = CoreNavigator.getCurrentPath();
461+
462+
return currentPath !== '/' && currentPath !== '/login';
463+
}, { timeout: 400 });
464+
465+
await CorePushNotificationsDelegate.clicked(data);
466+
446467
}
447468

448469
/**

0 commit comments

Comments
 (0)