@@ -23,7 +23,7 @@ import { CoreText } from '@singletons/text';
2323import { CoreQueueRunner } from '@classes/queue-runner' ;
2424import { CoreError } from '@classes/errors/error' ;
2525import { CoreConstants } from '@/core/constants' ;
26- import { makeSingleton , NgZone , Translate , LocalNotifications } from '@singletons' ;
26+ import { makeSingleton , NgZone , Translate , LocalNotifications , ApplicationInit } from '@singletons' ;
2727import { CoreLogger } from '@singletons/logger' ;
2828import {
2929 APP_SCHEMA ,
@@ -42,6 +42,9 @@ import { AsyncInstance, asyncInstance } from '@/core/utils/async-instance';
4242import { CoreDatabaseTable } from '@classes/database/database-table' ;
4343import { CoreDatabaseCachingStrategy , CoreDatabaseTableProxy } from '@classes/database/database-table-proxy' ;
4444import { CoreDomUtils } from './utils/dom' ;
45+ import { CoreSites } from './sites' ;
46+ import { CoreNavigator } from './navigator' ;
47+ import { CoreWait } from '@singletons/wait' ;
4548
4649/**
4750 * Service to handle local notifications.
@@ -87,7 +90,28 @@ export class CoreLocalNotificationsProvider {
8790 this . handleEvent ( 'trigger' , notification ) ;
8891 } ) ;
8992
90- this . clickSubscription = LocalNotifications . on ( 'click' ) . subscribe ( ( notification : ILocalNotification ) => {
93+ this . clickSubscription = LocalNotifications . on ( 'click' ) . subscribe ( async ( notification : ILocalNotification ) => {
94+ await ApplicationInit . donePromise ;
95+
96+ // This code is also done when clicking push notifications. If it's modified, it should be modified in there too.
97+ if ( CoreSites . isLoggedIn ( ) ) {
98+ CoreSites . runAfterLoginNavigation ( {
99+ priority : 0 , // Use a low priority because the execution of this process doesn't block the next ones.
100+ callback : async ( ) => {
101+ this . handleEvent ( 'click' , notification ) ;
102+ } ,
103+ } ) ;
104+
105+ return ;
106+ }
107+
108+ // User not logged in, wait for the path to be a "valid" path (not a parent path used when starting the app).
109+ await CoreWait . waitFor ( ( ) => {
110+ const currentPath = CoreNavigator . getCurrentPath ( ) ;
111+
112+ return currentPath !== '/' && currentPath !== '/login' ;
113+ } , { timeout : 400 } ) ;
114+
91115 this . handleEvent ( 'click' , notification ) ;
92116 } ) ;
93117
0 commit comments