electron-push-receiver icon indicating copy to clipboard operation
electron-push-receiver copied to clipboard

fcm/connect/subscribe 404 (not found)

Open sushan-shrestha opened this issue 1 year ago • 4 comments

I am receiving this issue in electron app from electron-push-receiver: PUSH_RECEIVER:::Error while starting the service StatusCodeError: 404 - "\n\n \n <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">\n

Error 404 (Not Found)!!1\n \n \n

404. That’s an error.\n

The requested URL /fcm/connect/subscribe was not found on this server. That’s all we know.\n" at new StatusCodeError (/home/outcode/Projects/aegix-beacon/node_modules/request-promise-core/lib/errors.js:32:15) at plumbing.callback (/home/outcode/Projects/aegix-beacon/node_modules/request-promise-core/lib/plumbing.js:104:33) at Request.RP$callback [as _callback] (/home/outcode/Projects/aegix-beacon/node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (/home/outcode/Projects/aegix-beacon/node_modules/request/request.js:185:22) at Request.emit (node:events:519:28) at Request. (/home/outcode/Projects/aegix-beacon/node_modules/request/request.js:1154:10) at Request.emit (node:events:519:28) at IncomingMessage. (/home/outcode/Projects/aegix-beacon/node_modules/request/request.js:1076:12) at Object.onceWrapper (node:events:633:28) at IncomingMessage.emit (node:events:531:35) at endReadableNT (node:internal/streams/readable:1696:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { statusCode: 404, ....

When I deep dive into the node_modules code, I can see that inside the electron-push-receiver, it is using push-receiver package which is then calling this code in index.js of push-receiver:

const FCM_SUBSCRIBE = 'https://fcm.googleapis.com/fcm/connect/subscribe'; const FCM_ENDPOINT = 'https://fcm.googleapis.com/fcm/send';

module.exports = registerFCM;

async function registerFCM({ senderId, token }) { const keys = await createKeys(); const response = await request({ url : FCM_SUBSCRIBE, method : 'POST', headers : { 'Content-Type' : 'application/x-www-form-urlencoded', }, form : { authorized_entity : senderId, endpoint : ${FCM_ENDPOINT}/${token}, encryption_key : keys.publicKey .replace(/=/g, '') .replace(/+/g, '-') .replace(///g, ''), encryption_auth : keys.authSecret .replace(/=/g, '') .replace(/+/g, '-') .replace(///g, ''), }, }); return { keys, fcm : JSON.parse(response), }; }

here when registering the fcm, it is trying to call this url https://fcm.googleapis.com/fcm/connect/subscribe which is no longer available and i am getting 404 which is causing my app not to register a fcm token.

How can this be worked on so that my app can register a fcm token and start getting the push notifications.

Thank you for the help.

sushan-shrestha avatar Nov 26 '24 09:11 sushan-shrestha

@sushan-shrestha were you able to figure this out ?

brightchamps-dev avatar Dec 28 '24 18:12 brightchamps-dev

@sushan-shrestha were you able to figure this out ?

Hi, there. try push-recevier-v2.

X-W-W avatar Jan 07 '25 12:01 X-W-W

@sushan-shrestha were you able to figure this out ?

I used firebase-electron to solve the issue. the implementation is somewhat same but we just need to pass more data on: ipcRenderer.send(START_NOTIFICATION_SERVICE, { apiKey: apiKey, appId: appId, projectId: projectId, vapidKey: vapidKey, });

sushan-shrestha avatar Jan 07 '25 12:01 sushan-shrestha

@sushan-shrestha were you able to figure this out ?

Hi, there. try push-recevier-v2.

Thanks I've solved it using firebase-electron

sushan-shrestha avatar Jan 07 '25 12:01 sushan-shrestha