This repository showcases a simple and effective script to send push notifications to Android devices using Firebase Cloud Messaging (FCM). Designed for developers, the code provides a quick setup for integrating FCM notifications with minimal configuration.
- Lightweight PHP implementation.
- Customizable notification content, including title, body, and icons.
- Detailed documentation for ease of use.
- Replace
YOUR-SERVER-API-ACCESS-KEY
with your FCM server key from the Google API Console. - Pass the device's registration ID via a GET request to the script.
- Execute the script to deliver the notification.
http://yourdomain.com/PhpFireBaseNotificationSample.php?id=DEVICE_REGISTRATION_ID
Thanks Pal
it worked like magic. So for the benefit of those struggling with this error
"{"multicast_id":5298140393388678667,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}"
I faced this for nearly a week only to discover that i was parsing a wrong device token. the reason being i was getting the token on device ready event through an alert() method. since i couldn`t copy it directly i had to screenshot the result then use some image to text app to get the token as string which is where i got it all wrong. To fix this i had to use use the whatsapp api to send the token to my account as plain text.
then it worked.