发送自定义数据以推送通知

时间:2019-11-19 06:58:40

标签: firebase push-notification ionic3

我在推送通知文档中看到了许多类型的数据,用于显示图标和自定义声音等。一个例子就像

{
    "aps" : {
        "alert" : "It's a notification with custom payload!",
        "badge" : 1,
        "content-available" : 0         
    },
    "data" :{
        "title" : "Game Request",
        "body" : "Bob wants to play poker",
        "action-loc-key" : "PLAY"
    },
}

但是我该如何发送这些数据?我可以通过Firebase控制台发送它吗?我在使用离子3的phonegap-plugin推送

1 个答案:

答案 0 :(得分:0)

图片

cordova.plugins.notification.local.schedule({
title: 'The big survey',
text: 'Are you a fan of RB Leipzig?',
attachments: ['file://img/rb-leipzig.jpg'],\\image binding
actions: [
    { id: 'yes', title: 'Yes' },
    { id: 'no',  title: 'No' }
]

});

小图标和&大图标

cordova.plugins.notification.local.schedule({
title: 'The Big Meeting',
text: '4:15 - 5:15 PM\nBig Conference Room',
smallIcon: 'res://calendar',
icon: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTzfXKe6Yfjr6rCtR6cMPJB8CqMAYWECDtDqH-eMnerHHuXv9egrw'

});

click here for official page