Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why don't you set public and private key after creating the pushService? #164

Open
AhmadAlhajKarim opened this issue Mar 22, 2021 · 3 comments

Comments

@AhmadAlhajKarim
Copy link

pushService.setPrivateKey(privateKey);
pushService.setPublicKey(publicKey);
This made my code working
Also don't forget to convert the payload to json string

@martijndwars
Copy link
Member

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)?

@AhmadAlhajKarim
Copy link
Author

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!

@newk5
Copy link

newk5 commented Dec 15, 2021

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>'})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants