How to know body of a push message?
Hello.
I ran a push demo and i now can see notification message. but. i do have a question. how to get a body message of the push notification?
thank you.
Where do you send the message from? AFAIK you need to encrypt the content properly for the browser to accept it. See also https://developers.google.com/web/updates/2016/03/web-push-encryption I made an attempt a while ago but some things are not yet available in Dart directly and I lack knowledge to implement the misding pieces myself. A simpler approach is to use push only to get notified about new messages and then make an extra request to get the body.
At the time I've last checked (several months ago) either Firefox or Chrome didn't support sending body content along with the notification. And even when they do, the crypto involved is not well documented (at least to my level), and I've opted to do the following workaround: when the SW receives a notification, either the worker or the app itself can query the server for more details, and receive the data on that follow-up request. It is a bit heavier on both the client and the server, but not too much.
I'll keep this open until I document this workaround somewhere, and if you happen to be into the crypto part, I'm open for PRs :)
@isoos seems you had a similar experience as I had. I got stuck on PointyCastle/pointycastle#112