You are here

function _firebase_buildMessage in Firebase Push Notification (FCM) 7

Builds the push notification body.

Parameters

string $appToken: Device token.

array $param: Parameters for payload.

Return value

array Prepared payload for push notification.

1 call to _firebase_buildMessage()
_firebase_sendPushNotification in ./firebase.module
Execute the push notification.

File

./firebase.module, line 168

Code

function _firebase_buildMessage($appToken, array $param) {

  // Parameters will be okay if we have at least the title and body.
  // If we do NOT have minimum fields, we assume it is a silent push.
  // Silent pushes need parameter data. So we check for $param['data'].
  // If these conditions are not met, we set a default value, just to go
  // through the push notification.
  if (!_firebase_isParamValid($param)) {
    return FALSE;
  }
  $mandatory = _firebase_addMandatoryFields($appToken);
  $optional = _firebase_addOptionalFields($param);
  $message = $mandatory + $optional;
  return json_encode($message);
}