MOBILE-4359 pushnotifications: Fix open push when app is dead

main
Dani Palou 2024-09-04 11:01:03 +02:00
parent 2c2508607a
commit 0e6058a242
2 changed files with 23 additions and 2 deletions

View File

@ -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);
}
/**

View File

@ -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<void> {
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);
}
/**