From 9649610e9158a4f7ace7a092bee5ecadc4ab26ff Mon Sep 17 00:00:00 2001 From: estevez-dev Date: Sun, 17 May 2020 01:08:55 +0300 Subject: [PATCH] Image support --- functions/worker.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/functions/worker.js b/functions/worker.js index e2d7285..41146e4 100644 --- a/functions/worker.js +++ b/functions/worker.js @@ -1,7 +1,9 @@ module.exports = { createPayload: function createPayload(req) { var payload = { - android: {}, + android: { + collapseKey: "haclient" + }, notification: {}, data: { click_action: "FLUTTER_NOTIFICATION_CLICK" @@ -13,24 +15,16 @@ module.exports = { // Allow setting of ttl // https://firebase.google.com/docs/reference/admin/node/admin.messaging.AndroidConfig.html#optional-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 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 - for (const key of [ - '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]) - } + if (req.body.data.image) { + payload.notification.image = req.body.data.image; } }