Open AhmadAlhajKarim opened 3 years ago
Thanks for the feedback! Just to see if I understand you correctly; are you saying the documentation/example is unclear/misses these calls? If yes, can you point me to the documentation (wiki/readme)?
Yes, in the documentation of the usage example is not been mentioned where to use the private and the public key. Missing calls is after initializing the pushService.
//Instantiate the push service, no need to use an API key for Push API
pushService = new PushService();
//set the pivate and the public key
pushService.setPrivateKey(privateKey);
pushService.setPublicKey(publicKey);
// Send the notification
pushService.send(notification);
Thank you!
Thank you, I was having the same issues and the documentation misslead me too.
I noticed on the java side those calls were missing just like you said, but on the client side it's missing the public key too! This javascript code:
serviceWorkerRegistration.pushManager.subscribe({userVisibleOnly: true})
Should be:
serviceWorkerRegistration.pushManager.subscribe({userVisibleOnly: true, applicationServerKey: '<publicKey here>'})
pushService.setPrivateKey(privateKey); pushService.setPublicKey(publicKey); This made my code working Also don't forget to convert the payload to json string