GoogleChromeLabs / web-push-codelab

Other
557 stars 293 forks source link

Invalid registration error while executing the curl cmd #16

Closed bvakiti closed 7 years ago

bvakiti commented 7 years ago

I have couple of questions

  1. is it necessary to create sample Project name in Firebase or just sender_id match would help?

  2. After opening my project in chrome web server, I used the curl cmd to send the notification curl --header "Authorization: key=AIzaSyBjxxxxxx" --header "Content-Type: application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"xxxx\"]}"

This throws error {"multicast_id":7720103039622715939,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}

I have tried all the possibilites. How to resolve this

Is there any other way to write code for sending push notifications other than curl ?

gauntface commented 7 years ago

the curl command needs to have the double quotes escaped OR use use single quotes, like this:

curl --header "Authorization: key=AIzaSyBjxxxxxx" --header "Content-Type: application/json" https://android.googleapis.com/gcm/send -d '{"registration_ids":["xxxx"]}'