You are here

public function FirebaseMessageService::setData in Firebase Push Notification (FCM) 8

Same name and namespace in other branches
  1. 3.0.x src/Service/FirebaseMessageService.php \Drupal\firebase\Service\FirebaseMessageService::setData()

Add data to message.

Parameters

array $data: Data options.

File

src/Service/FirebaseMessageService.php, line 98

Class

FirebaseMessageService
Service for pushing message to mobile devices using Firebase.

Namespace

Drupal\firebase\Service

Code

public function setData(array $data) {
  if ($this
    ->checkReservedKeywords($data)) {
    $this->body['data'] = $data;
  }
  else {
    throw new \InvalidArgumentException('Keys in data shouldn\'t contain "form" and any keys starting with "google" and "gcm".');
  }
}