Closed koderyoda closed 8 years ago
Here is my little test script that is supposed to send the chrome notification:
import * as chromePusher from 'web-push-encryption'; export function sendChromeNotification() { let subscription = { "endpoint":"https://android.googleapis.com/gcm/send/**********", "keys":{"p256dh":"***********-*********=", "auth":"*******=="} }; chromePusher.setGCMAPIKey("**********"); let dataPayload = "test string"; chromePusher.sendWebPush(dataPayload, subscription) .then((response) => console.log("push response=", JSON.stringify(response))) .catch((err) => console.log("push error=", JSON.stringify(err))); }
This is the response printed in console: "push response= {\"statusCode\":201,\"statusMessage\":\"Created\",\"body\":\"\"}
"push response= {\"statusCode\":201,\"statusMessage\":\"Created\",\"body\":\"\"}
But no notification is received in the browser.
But but, if I set dataPayload to blank, then the notification is received. Except of course it defeats the purpose.
Don't know if this is a library problem or GCM but any pointers would help.
This whole setup is running on localhost, not sure if that could be a problem for the browser to reject the notification and how to fix it.
ok I switched to my domain with https and local host file mapping and this worked, getting the data alright. Thanks.
Here is my little test script that is supposed to send the chrome notification:
This is the response printed in console:
"push response= {\"statusCode\":201,\"statusMessage\":\"Created\",\"body\":\"\"}
But no notification is received in the browser.
But but, if I set dataPayload to blank, then the notification is received. Except of course it defeats the purpose.
Don't know if this is a library problem or GCM but any pointers would help.
This whole setup is running on localhost, not sure if that could be a problem for the browser to reject the notification and how to fix it.