Skip to Content
API v1EndpointsNotifications Endpoints

Notifications Endpoints

Update FCM Token

File: api/updateFCM.php Method: POST Auth: Required JWT (POST body)

ParamTypeDescription
jwtstringUser JWT
fcm_tokenstringFirebase Cloud Messaging token (empty string to clear)

Updates the user’s FCM token in the users table. Called when the app registers/refreshes its push notification token. If fcm_token is empty, sets the column to NULL (unregisters the device).

Notification Opened

File: api/notificationOpened.php Method: POST Auth: Required JWT

Records that a user opened/read a notification.

Reminder Notification

File: api/reminderNotification.php Method: POST

Triggers reminder notifications. Used by scheduled jobs.

Notification Utilities

sendNotification (FCM)

File: api/utils/notificationUtils.php

sendNotification(string $title, string $body, array $data = [], array $fcmTokens = [])

Sends push notifications via Firebase Cloud Messaging using the Kreait Firebase SDK. Iterates through provided FCM tokens and sends individual messages with highest priority. Silently catches errors per token (e.g., expired tokens).

sendText (SMS)

File: api/utils/notificationUtils.php

sendText(array $numbers, string $text)

Sends SMS messages via Twilio. Uses the global $ttoken (Twilio auth token) and $USA flag. Normalises phone numbers before sending.

  • US: From phone number +14027611623
  • UK: From sender ID Housr

sendSMS (Dedicated)

File: api/utils/sendSMS.php

sendSMS(array $numbers, string $text)

Standalone SMS function (similar to sendText in notificationUtils). Same Twilio credentials and regional logic.

Scheduled Notifications

Add Scheduled Notification

File: api/utils/addScheduledNotification.php

Inserts a notification into the scheduled_notifications table for future delivery.

Add Scheduled Notifications on Viewing Request

File: api/utils/addScheduledNotificationsOnViewingRequest.php

Creates the standard set of notifications when a viewing is requested (pre-viewing reminder, post-viewing follow-up).

Add Scheduled Viewing Notification

File: api/utils/addScheduledViewingNotification.php

Viewing-specific scheduled notification.

Add Scheduled Viewing Text

File: api/utils/addScheduledViewingText.php

Schedules an SMS for a viewing.

Add Scheduled Text to Multiple Users

File: api/utils/addScheduledTextToMultipleUsers.php

Schedules SMS for multiple users.

Notification Flow

  1. Token Registration: App sends FCM token via updateFCM.php on launch
  2. Event-Triggered: Endpoints like requestViewing.php create scheduled notifications in the database
  3. Scheduled Delivery: A separate process reads scheduled_notifications and sends via sendNotification()
  4. Portal Notifications: Agent-facing notifications are stored in portal_notifications table
  5. Tracking: notificationOpened.php records when users interact with notifications

Push notifications are sent via the Kreait Firebase SDK. The Firebase connection is established in api/include/dbcon.php:

$factory = (new Factory) ->withServiceAccount(json_decode($_ENV['FIREBASE_CREDENTIALS'], true)) ->withDatabaseUri($_ENV['FIREBASE_DATABASE_URL']); $messaging = $factory->createMessaging();

The $messaging object is used globally by notification utility functions.

Last updated on