Documentation menu

Setting up Firebase (push notifications)

Push notifications use Firebase Cloud Messaging (FCM). The API sends them with the FCM HTTP v1 API using a service account, and the app receives them with the Firebase SDK.

1. Create the Firebase project

  1. Go to the Firebase console → Add project. Google Analytics is optional.
  2. Add an Android app with your package name (e.g. com.yourcompany.app) and download google-services.json.
  3. Add an iOS app with your bundle ID and download GoogleService-Info.plist.
  4. iOS only: under Project settings → Cloud Messaging → Apple app configuration, upload your APNs authentication key (.p8 from Apple Developer → Keys, with "Apple Push Notifications service" enabled), plus its Key ID and your Team ID.

Where the app expects these files, iOS APNs setup and how the app handles pushes: see push-notifications.md. Never commit them to a public repository.

2. Give the API a service account

  1. In Firebase → Project settings → Service accounts, click Generate new private key. A JSON file downloads.
  2. In Admin → Settings → Integrations → Firebase, paste the whole JSON file. It is stored encrypted.

That's all. Without this setting, push is off. In-app notifications and emails still work.

3. What the app sends and receives

  • After login, and whenever the token changes or the user switches between customer and provider mode, the app calls POST /api/v1/devices with token, platform (android/ios) and app_mode (customer/provider). On logout it calls DELETE /api/v1/devices/{token}.
  • Every push has data.type and data.link, the deep-link path to open on tap (e.g. /bookings/HS-7K3P9Q), plus ids such as booking_code or job_id.
  • Provider notifications go only to devices registered in provider mode, and customer notifications to customer mode. Account notices (approval, payments) go to every device.
  • Titles and texts are in the recipient's language (their locale).
  • Users can switch push off per group (bookings, jobs, chat, marketing) under PATCH /api/v1/me/notification-settings. Payment and account notices are always sent.
  • Tokens that FCM reports as no longer valid are deleted automatically.

Queue

Notifications are queued. Run php artisan queue:work (or Supervisor/systemd in production). On shared hosting without a long-running worker, see the cPanel install guide (cron-based queue).