【问题标题】:Go to a specific path when Click on Ionic local notification单击 Ionic 本地通知时转到特定路径
【发布时间】:2020-05-03 09:08:54
【问题描述】:

例如,我收到了来自特定任务提醒的本地通知。当我单击通知时,我想使用路径转到该特定任务页面。如何做到这一点,我正在使用 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】:

    从通知中,我想您得到了与它相关的任务 ID 之类的东西。您需要做的就是注入角度路由器并在收到通知时使用导航方法。

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

    有关路由器的更多信息,请点击此处:https://angular.io/guide/router

    【讨论】:

    • 但是如何从通知中检索taskId?
    • 这实际上取决于通知的实现方式,例如特定的库。通知肯定有内容,其中应包括任务 ID。如果您无法控制此通知并且其中没有任务 ID,那么您在前端无能为力...
    猜你喜欢
    • 2015-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-01
    • 2018-09-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多