3

I want to send web push notification to my clients using gcm. There are many libraries for many languages to encrypt the payload. I use ruby Webpush gem for encrypt the payload and send the notification. As far as I see this library encrypts the payload as octet stream and sends the result with octet-stream content type to GCM. How can I include registration_ids in the request body?

Aref Aslani
  • 1,560
  • 13
  • 27
  • the problem is that GCM doesn't understand octet-stream? it should be sent as json? – Aleksey Sep 24 '16 at 15:46
  • @Aleksey: GCM understands, but my problem is how to generate message payload and subscription ids array. Should I create a json containing the message object and the registeration_ids array and then encrypt that? – Aref Aslani Sep 24 '16 at 18:17
  • to be honest I never worked with push messages. I think you should just try and see what happens. – Aleksey Sep 24 '16 at 18:24
  • The json approach seems logical. What is holding you back from trying/using this? – max pleaner Sep 24 '16 at 19:00
  • @maxpleaner: Because libraries I have seen their source code, send request body as octet-stream and I use these libraries to encrypt message payload... See [PHP](https://github.com/web-push-libs/web-push-php/blob/master/src/WebPush.php#L197) or [Ruby](https://github.com/zaru/webpush/blob/master/lib/webpush/request.rb#L36) – Aref Aslani Sep 25 '16 at 05:51

0 Answers0