-1

Example , i have received a localnotification from a specific task reminder . When i click on the notification i want to go that specific task page with a path . How to do that , i am using ionic cordova local notification plugin , also capacitor push notification .

reminderNotification(id , sec: number , msg , dueDate , dueTime) {
        const endTime = sec;
        const startTime = this.converToMinutes(dueTime);
        const converted = this.parseTime(startTime - endTime);
        const date = new Date(dueDate + ' ' + converted );
        // tslint:disable-next-line:radix
        this.localNotification.clear( parseInt(id) ).then(
            () => {
                this.localNotification.schedule({
                    // tslint:disable-next-line:radix
                    id: parseInt(id),
                    title: ' Attention ! ' + converted ,
                    text: 'Your Task "' + msg + '" will expire soon' ,
                    // data: {msg : 'Lots of data'},
                    trigger: {
                        at: date,
                        // unit: ELocalNotificationTriggerUnit.SECOND
                    },
                    silent: false,
                    lockscreen : true,
                    foreground : true,
                    vibrate : true
                });
            }
        );
    }
Md omer arafat
  • 398
  • 7
  • 10

1 Answers1

1

From the notification, I imagine you got something like the task id related to it. All you need to do is inject the angular router and use the navigate method when the notification is received.

this.router.navigate(['/TASKS_ROOT_PAGE/TASK_ID']);

More info about the router are available here: https://angular.io/guide/router

michelepatrassi
  • 2,016
  • 18
  • 32
  • But how to retreve the taskId from notifcation ? – Md omer arafat May 03 '20 at 15:50
  • this really depends on how the notification is implemented, for example a specific library. The notification has content for sure, which should include the task id. If you have no control on this notification and there is no task id in it, there is not much you can do on the frontend... – michelepatrassi May 04 '20 at 07:04