From 4d4ea73ff2bc949602d1cd58af4201b419b0f496 Mon Sep 17 00:00:00 2001 From: "ITHQ1947\\saritha.pillai" Date: Thu, 4 Jan 2024 11:19:30 +0530 Subject: [PATCH] Upgrade push notifications to Firebase HTTP v1 API --- app.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 6b5c65e..615c072 100644 --- a/app.js +++ b/app.js @@ -90,13 +90,13 @@ async function APNSpush(certificate, device, payload) { // Send a Firebase (Google) push notification using `certificate` to the specified `device`. async function GCMpush(certificate, device, payload) { - const client = http2.connect("https://fcm.googleapis.com:443") - const buffer = Buffer.from(JSON.stringify({ - ...payload, "to": device - })) + const client = http2.connect("https://fcm.googleapis.com:443/v1/projects/api-6882780734960683553-445906") + const buffer = Buffer.from(JSON.stringify({message:{ + ...payload, "token": device + }})) const request = client.request({ [':method']: 'POST', - [':path']: `/fcm/send`, + [':path']: `/messages:send`, "Content-Type": "application/json", "Content-Length": buffer.length, "Authorization": `Bearer ${certificate}`,