Image support
This commit is contained in:
parent
68a7080a5b
commit
9649610e91
@ -1,7 +1,9 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
createPayload: function createPayload(req) {
|
createPayload: function createPayload(req) {
|
||||||
var payload = {
|
var payload = {
|
||||||
android: {},
|
android: {
|
||||||
|
collapseKey: "haclient"
|
||||||
|
},
|
||||||
notification: {},
|
notification: {},
|
||||||
data: {
|
data: {
|
||||||
click_action: "FLUTTER_NOTIFICATION_CLICK"
|
click_action: "FLUTTER_NOTIFICATION_CLICK"
|
||||||
@ -13,24 +15,16 @@ module.exports = {
|
|||||||
// Allow setting of ttl
|
// Allow setting of ttl
|
||||||
// https://firebase.google.com/docs/reference/admin/node/admin.messaging.AndroidConfig.html#optional-ttl
|
// https://firebase.google.com/docs/reference/admin/node/admin.messaging.AndroidConfig.html#optional-ttl
|
||||||
if (req.body.data.ttl) {
|
if (req.body.data.ttl) {
|
||||||
payload.android.ttl = req.body.data.ttl
|
payload.android.ttl = req.body.data.ttl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://firebase.google.com/docs/reference/admin/node/admin.messaging.AndroidConfig.html#optional-priority
|
// https://firebase.google.com/docs/reference/admin/node/admin.messaging.AndroidConfig.html#optional-priority
|
||||||
if (req.body.data.priority) {
|
if (req.body.data.priority) {
|
||||||
payload.android.priority = req.body.data.priority
|
payload.android.priority = req.body.data.priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://firebase.google.com/docs/reference/admin/node/admin.messaging.AndroidNotification.html
|
if (req.body.data.image) {
|
||||||
for (const key of [
|
payload.notification.image = req.body.data.image;
|
||||||
'icon', 'color', 'sound', 'tag', 'clickAction',
|
|
||||||
'bodyLocKey', 'bodyLocArgs', 'titleLocKey', 'titleLocArgs', 'channelId',
|
|
||||||
'ticker', 'sticky', 'eventTime', 'localOnly', 'notificationPriority',
|
|
||||||
'defaultSound', 'defaultVibrateTimings', 'defaultLightSettings', 'vibrateTimings',
|
|
||||||
'visibility', 'notificationCount', 'lightSettings', 'image']) {
|
|
||||||
if (req.body.data[key]) {
|
|
||||||
payload.data[key] = String(req.body.data[key])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user