gpt4 book ai didi

ionic-framework - ionic 2/3 中的一个信号附加数据

转载 作者:行者123 更新时间:2023-12-05 00:50:53 24 4
gpt4 key购买 nike

我正在尝试在我的 ionic 2 应用程序中使用一个信号插件

我已经安装了 Onesignal 并且工作正常,但我不知道如何使用 handleNotificationOpened功能
根本没有文件(没有找到)

这是我的代码:

this.oneSignal.handleNotificationReceived().subscribe((msg) => {
// o something when notification is received
});

但我不知道如何使用 msg用于获取数据。

有什么帮助吗?关联?
保护你

最佳答案

这是当应用程序从通知启动时将用户重定向到相关页面的方式。

app.component.ts

this.oneSignal.handleNotificationOpened().subscribe((data) => { 
let payload = data; // getting id and action in additionalData.
this.redirectToPage(payload);
});


redirectToPage(data) {
let type
try {
type = data.notification.payload.additionalData.type;
} catch (e) {
console.warn(e);
}
switch (type) {
case 'Followers': {
this.navController.push(UserProfilePage, { userId: data.notification.payload.additionalData.uid });
break;
} case 'comment': {
this.navController.push(CommentsPage, { id: data.notification.payload.additionalData.pid })
break;
}
}
}

关于ionic-framework - ionic 2/3 中的一个信号附加数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45200193/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com