Firebase HTTP v1 Configuration

Firebase HTTP v1 (Cloud Messaging) is the recommended push notification backend for PNFPB. It supports both web browsers and Android/iOS mobile apps via a secure OAuth 2.0 service account.

A YouTube tutorial for Firebase setup is linked from the plugin’s Firebase configuration admin tab.

Step 1 – Create a Firebase Project

  1. Open Firebase Console and click Add project.
  2. Name your project, enable Google Analytics if desired, and click Create project.

Step 2 – Register a Web App

  1. In the project overview click the </> Web icon to add a web app.
  2. Give it a nickname and click Register app.
  3. Firebase shows the firebaseConfig object – copy these values for use in step 4.

Step 3 – Generate the Web Push (VAPID) Key Pair

  1. In Firebase Console go to Project settings → Cloud Messaging.
  2. Scroll to Web configuration → Web Push certificates.
  3. Click Generate key pair. Copy the resulting Public key.
  4. If you already generated one, retrieve it from the same location – do not generate a second pair, it will invalidate existing subscriber tokens.

Step 4 – Enter Credentials in Plugin Settings

In PNFPB Settings → Firebase configuration fill in:

Setting Label Firebase field Where to find it
API Key apiKey firebaseConfig object → General tab
Auth Domain authDomain firebaseConfig → General
Database URL databaseURL firebaseConfig → General (may be empty for new projects)
Project ID projectId firebaseConfig → General
Storage Bucket storageBucket firebaseConfig → General
Messaging Sender ID messagingSenderId firebaseConfig → General
App ID appId firebaseConfig → General
Measurement ID measurementId firebaseConfig → General (optional)
Public Key (VAPID) VAPID public key Cloud Messaging → Web Push certificates

Step 5 – Upload the Service Account JSON (HTTP v1)

  1. In Firebase Console go to Project settings → Service accounts.
  2. Click Generate new private key and download the JSON file.
  3. In PNFPB settings go to Firebase Service Account and upload the JSON file using the admin file upload.
  4. Enable Firebase HTTP v1 toggle.

OAuth Token Auto-Refresh

After enabling HTTP v1 the plugin schedules an hourly WP Cron job (PNFPB_cron_generate_Firebase_oauth_token_hook) to refresh the OAuth 2.0 access token. The token is stored in the WordPress options table (pnfpb_firebase_oauth_token + pnfpb_firebase_oauth_timestamp). If the token is older than 1 hour it is automatically regenerated before the next notification is sent.

Important: WP Cron requires at least one visitor to your site to trigger scheduled events. On low-traffic sites consider setting up a real server cron that calls wp-cron.php every 5–10 minutes.