Closed riatzukiza closed 5 years ago
Electron doesn't implement the PushManager API so you can't use a serviceWorker registration to receive push notifications. It's the reason why I created push-receiver in the first place.
Using electron-push-receiver
, you'll receive a TOKEN_UPDATED
event with the token you can use to send a push notification. To setup this library, you just need to follow the README.
I understand that, I don't want the service worker. I want to get the endpoint url with out invoking all that browser stuff. is there a way to generate it from the token?
The endpoint to use to send notifications is the FCM one. You can find an example here https://github.com/MatthieuLemoine/push-receiver/blob/master/scripts/send/index.js#L21
I saw that, the issue I'm having is I'm working on an electron client to a backend I don't have much control over, and they are sending the exact url that the browser would usually give them, and doing push notifications with that url. The url the browser gives looks like https://android.google.com/gcm/send/oig9h238h49fsf7....
The fact that it was gcm that the chromium browser gave back was a little funny to me.
I've been hunting all around to see if I can get a url similar to that, that wouldn't require that back end to be changed.
If I could also know for sure that I couldn't do it with the token I get back from this library, that'd be fine and I just need to wait on the backend to be modified to accept a token.
I guess you could try https://fcm.googleapis.com/fcm/send/${token}
, it's what we use to register to FCM https://github.com/MatthieuLemoine/push-receiver/blob/817c843c0689d0b73b823485012897d7b02a168e/src/fcm/index.js#L20
I get a log in my browser that I have successfully subscribed to a push api, but I get nothing. I am migrating an existing push api service from a website to an electron client.
How do I generate the endpoint url from the token data I'm provided from this library?