首页 > 解决方案 > 发送自定义数据推送通知

问题描述

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

{
    "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控制台发送它吗?我正在为 ionic 3 使用 phonegap-plugin push

标签: firebasepush-notificationionic3

解决方案


图片

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'

});

点击这里进入官方页面


推荐阅读