0

I have been using this npm module in my React native project https://github.com/zo0r/react-native-push-notification for push notifications. On Ios everything is working fine. but on Android I am not able to send push message from my php server. However I am successfully getting device token on my Android device. I am using Api key on php side and getting error 401 unauthorised. My php code is copied from here https://gist.github.com/prime31/5675017

Any help?

h_h
  • 1,201
  • 4
  • 28
  • 47
  • You may want to refer with these posts: [1](https://stackoverflow.com/questions/12619759/google-gcm-server-returns-unauthorized-error-401) and [2](https://stackoverflow.com/questions/37789264/api-key-for-gcm-is-suddenly-invalid-unauthorized-401-error/37801206#37801206). If you've suddenly started experiencing this error without making any specific changes (the Server Key) still the same, you probably need to import your project to Firebase. Also, try to whitelist the IP of your server. This is not necessary by default for the browser key, but it is for the server key. – abielita Dec 28 '17 at 15:05

1 Answers1

0

Error code 401 means the sender account used to send a message couldn't be authenticated. Possible causes are: 1. Authorization header missing or with invalid syntax in HTTP request. 2. Invalid project number sent as key. 3. Key valid but with GCM service disabled. 4. Request originated from a server not whitelisted in the Server Key IPs.

Refer to this doc for more details

Umang
  • 966
  • 2
  • 7
  • 17