From 7b8a213808a579a5d044bfc82fe2e723eb10f93e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 2 Sep 2024 10:34:30 +0300 Subject: sender: `firebase-admin` compatibility --- vnext/server/sender.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'vnext') diff --git a/vnext/server/sender.js b/vnext/server/sender.js index be907059..fa8c4853 100644 --- a/vnext/server/sender.js +++ b/vnext/server/sender.js @@ -19,20 +19,22 @@ const apnConfig = (production = true) => { } return apn } -const gcmConfig = { - ...cfg.gcm, - id: cfg.gcm?.id || process.env.JUICK_GCM_ID +const fcmConfig = { + ...cfg.fcm, + serviceAccountKey: process.env.JUICK_FCM_SERVICE_ACCOUNT_FILE } +console.log(`fcm config: ${JSON.stringify(fcmConfig)}`) + const push = new PushNotifications({ ...config, apn: apnConfig(true), - gcm: gcmConfig, + fcm: fcmConfig, }) const sandbox = new PushNotifications({ ...config, apn: apnConfig(false), - gcm: gcmConfig + fcm: fcmConfig }) /** @type {string} */ @@ -139,14 +141,18 @@ export function buildNotification(user, msg) { template.text2 = body template.title = title template.body = body - template.badge = user.unreadCount || 0 + //template.badge = user.unreadCount || 0 template.mutableContent = 1 template.color = '#3c77aa' template.icon = 'ic_notification' template.clickAction = 'com.juick.NEW_EVENT_ACTION' const tag = msg.mid == 0 ? msg.user.uname : msg.mid template.tag = `${tag}` - template.android_channel_id = 'default' + template.fcm_notification = { + title: title, + body: body, + channel_id: 'default' + } } return template } -- cgit v1.2.3