4

Using v4.0.10 of Pushsharp (nuget package), I am getting error GCM Authorization Failed when sending push notifications to Android devices.

Seems the bug raised in issue 574 (https://github.com/Redth/PushSharp/issues/574 ) has been compiled into the nuget package, yet I'm still getting this error.

Could this be related to the introduction of Firebase Cloud Messaging?

Does anyone still have success using GCM?

conbask
  • 9,741
  • 16
  • 57
  • 94
Ernie P
  • 43
  • 1
  • 4
  • Are you using the correct Server Key? – AL. Nov 15 '16 at 09:31
  • I believe so - I haven't changed my code since we last used push sharp successfully a few months ago.The google play console / google api console has changed since the introduction of FCM and I can no longer find the location of the server key. Are you able to direct me where this key can be obtained? – Ernie P Nov 15 '16 at 22:14
  • I've added in an answer. Let me know how if it works. – AL. Nov 16 '16 at 04:40

2 Answers2

5

As of right now, GCM is still usable. However, it is highly encouraged for new users to use FCM instead. Either way, for both GCM and FCM, you must use a Server Key generated from the Firebase Console. There is a visible note in the GCM docs saying:

Starting from Sept. 2016 new server key can only be created in the Firebase Console using the Cloud Messaging tab of the Settings panel. Existing projects that need to create a new server key can be imported in the Firebase console without affecting their existing configuration.

The Authorization error has been encountered by number of users, some also had an old project. See my answer here for more details.

Community
  • 1
  • 1
AL.
  • 36,815
  • 10
  • 142
  • 281
  • 1
    I've imported my project into Firebase. My server application that sends the push notifications is now using the Server Key from Firebase Console -> Project Settings -> Cloud Messaging. However, I'm now receiving error MismatchSenderId. Using the "Firebase Cloud Messaging token" renders the same result. Seems like a slightly better situation. My app in Google Developer Console has the Sender Id from Firebase Console in the "Linked Sender IDs" section. – Ernie P Nov 17 '16 at 06:31
  • In Google API Manager, i can see the Server key that was generated ("Server key (auto created by Google Service)"). I saw a comment suggesting to add a restriction (my IP address), but this did not help. – Ernie P Nov 17 '16 at 06:36
  • @ErnieP The restriction is optional, but recommended. The [MismatchSenderId](https://firebase.google.com/docs/cloud-messaging/http-server-ref#error-codes) should only occur if you are using a Sender ID that is not associated to the registration token. Can you give a link where you're seeing the Linked Sender ID? – AL. Nov 17 '16 at 07:20
  • My app code registers push notifications with Sender Id 83XXXXXX37. In the Services & APIs section of my App in GooglePlay Developer Console, This 83XXXXXX37 sender id is listed, as well as another two sender Ids (54XXXXXX73, 57XXXXXX54). My server code that sends the push notifications, uses the 54XXXXXX73 sender id, and the corresponding server key for that sender id in Firebase. It seems like I need to somehow create a firebase project that uses the 83XXXXXX37 sender id, but i cant see any option to edit. I dont have a project to import that has that sender id attached to it. – Ernie P Nov 17 '16 at 23:14
0

The sender id used in the app code needs to match the sender id Firebase Cloud Message Console and its corresponding "Firebase Cloud Messaging token".

Thank you @AL for your help.

Ernie P
  • 43
  • 1
  • 4
  • You're welcome. Make sure to accept a ***correct answer*** here so that your post will be properly tagged. Cheers! – AL. Nov 18 '16 at 01:43