当点击Ionic本地通知时,转到特定路径。

问题描述 投票:0回答:1

例如,我收到了一个来自本地的特定任务提醒通知。当我点击通知时,我想去该特定任务页面的路径。如何做到这一点,我使用的是ionic cordova本地通知插件,也有电容推送通知。

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
                });
            }
        );
    }
angular ionic-framework push-notification localnotification capacitor
1个回答
0
投票

从通知中,我猜想你得到了类似任务id的相关信息。你需要做的就是注入angular router,在收到通知时使用navigate方法。

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

更多关于路由器的信息可以在这里找到。https:/angular.ioguiderouter)。

© www.soinside.com 2019 - 2024. All rights reserved.