Skip to content

About

PHP relay and web console for testing Firebase Cloud Messaging (FCM v1) and APNs push notifications.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Firebase Notifications Debug Console

Web console and PHP relay for exercising Firebase Cloud Messaging (FCM) push notifications with optional APNs payload fields.

Why

Building custom Firebase notifications usually means guessing at the payload, sending it, and checking a phone to see what arrived. This console lets you write a notification (title, body, image, data JSON, priority), send it to specific browser or mobile device tokens, and see right away how it shows up on screen or on the device, along with the exact payload that was received.

It also works as reference code for the whole flow: registering the browser and its service worker for notifications, managing device tokens, and a PHP relay that sends messages through the FCM HTTP v1 API using short-lived OAuth tokens from a service account.

Firebase Notifications Debug Console

Project setup

1) Server setup

  • Serve the console over HTTPS (trusted cert or http://localhost for local dev) because Firebase Messaging requires a secure origin.

2) Install Composer dependencies

  • From the ext/ directory run composer install.
  • The ext/vendor/ directory is ignored in Git; rerun the command after cloning or whenever dependencies change.

3) Create a Firebase project

4) Obtain Google Service Account Key (for FCM v1)

The steps below produce the service account key required to mint the short-lived OAuth 2.0 access token (rotated roughly every 1800s) that authenticates requests to the Firebase v1 send API.

  1. Open Firebase Console: https://console.firebase.google.com
  2. Select your project.
  3. Click the gear icon next to "Project Overview" and choose "Project settings".
  4. Open the "Service accounts" tab.
  5. Under "Firebase Admin SDK", click "Generate new private key".
  6. Downloaded key file will be saved locally.
  7. Place the key file in cfg/gcloud/service_account_keys/.
  8. Reference the filename in cfg/config.php via $config['firebase']['service_account_key'].

Console

  • Available at /console/; registers browser tokens and triggers test notifications via push_notifications.php.
  • Firebase web setup pulls config from console/config_js.php so secrets stay outside the repo (cfg/config.php).
  • Console UI lets you enter device tokens, title/body/image/data JSON, priority, and previews the payload.
  • FCM targeting: only token is supported today; topic and condition targets are not yet implemented.

Known Issues

1) Chrome service worker fails with SSL error:

In some local or test setups, Chrome may fail to register the service worker with an error such as:

Service worker registration failed: An SSL certificate error occurred when fetching the script.

This happens when the app is served over HTTPS with a self-signed or otherwise untrusted certificate. Chrome only allows service workers on fully trusted secure origins, so if the certificate is not trusted by the operating system, Chrome treats the connection as insecure and blocks service worker registration. Manually bypassing the HTTPS warning is not enough; the certificate must be trusted at the OS level.

Workarounds:

  • Use http://localhost for development (Chrome treats it as a secure context), or
  • Install the self-signed/CA certificate into the system’s trusted root store so Chrome accepts the HTTPS origin as valid.
  • Use Firefox for local testing, which is more permissive with manually accepted self-signed certificates (though trusting the certificate at the OS level is still recommended).

License

MIT Licence

About

PHP relay and web console for testing Firebase Cloud Messaging (FCM v1) and APNs push notifications.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages