You are here

function firebase_checkReservedKeywords in Firebase Push Notification (FCM) 7

Validate reserved keywords on data.

The key should not be a reserved word ("from" or any word starting with "google" or "gcm"). Do not use any of the words defined here https://firebase.google.com/docs/cloud-messaging/http-server-ref.

Not checking ALL reserved keywords. Just eliminating the common ones. Created this function to document this important restriction.

Parameters

array $data: Params that builds Push notification payload.

Return value

bool TRUE if keys are fine, and FALSE if not.

1 call to firebase_checkReservedKeywords()
_firebase_isParamValid in ./firebase.module
Validate mandatory data on received parameters.

File

./firebase.module, line 293

Code

function firebase_checkReservedKeywords($data) {
  foreach ($data as $key => $value) {
    if (preg_match('/(^from$)|(^gcm)|(^google)/', $key)) {
      return FALSE;
    }
  }
  return TRUE;
}