1

I am building a backend with Ruby (padrino framework) and would like to send push notification. I used this gem for push notification.

https://github.com/spacialdb/fcm

I used server key from firebase console could setting. This is code what I have used.

fcm = FCM.new(settings.fcm_serverkey)
registration_ids= [settings.test_key] 
options = {data: {score: "123"}, collapse_key: "updated_score"}
response = fcm.send(registration_ids, options)

And this is error what I got.

{:body=>"{\"multicast_id\":8815634661444747749,\"success\":0,\"failure\":1,\"canonical_ids\":0,\"results\":[{\"error\":\"MismatchSenderId\"}]}", :headers=>{"content-type"=>["application/json; charset=UTF-8"], "date"=>["Wed, 20 Dec 2017 21:05:04 GMT"], "expires"=>["Wed, 20 Dec 2017 21:05:04 GMT"], "cache-control"=>["private, max-age=0"], "x-content-type-options"=>["nosniff"], "x-frame-options"=>["SAMEORIGIN"], "x-xss-protection"=>["1; mode=block"], "server"=>["GSE"], "alt-svc"=>["hq=\":443\"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=\":443\"; ma=2592000; v=\"41,39,38,37,35\""], "accept-ranges"=>["none"], "vary"=>["Accept-Encoding"], "connection"=>["close"]}, :status_code=>200, :response=>"success", :canonical_ids=>[], :not_registered_ids=>[]}

What the important thing is "MismatchSenderId" from error log. I can't find param for senderID in github guide. They only mentioned about serverkey. Any advice will be big help for me. Thanks

Nomura Nori
  • 4,689
  • 8
  • 47
  • 85
  • You sure you are using right token for right project? [check_out_this_answer](https://codedump.io/share/wdirXzlaIuaY/1/firebase-mismatchsenderid-when-authorization-key-is-my-server-key) And you checked out [this SO question](https://stackoverflow.com/questions/37863106/fcm-getting-mismatchsenderid)? – Martin Dec 20 '17 at 23:39
  • Did you find anything in the last month? – Dylanthepiguy Jan 18 '18 at 23:27
  • hi do you find the solution – Humayun Naseer Jan 14 '21 at 13:22

1 Answers1

0

I was going through the same issue recently. In my case, I was not using the correct Server-ID because we have to use the Server-Id from the project where our app has been registered.

You can check this in Google-services.json

secondly please ensure that you allowed and added your App to your Firebase project.

I find the best reason explanation here

Humayun Naseer
  • 440
  • 7
  • 18