public function FirebaseMessageService::setRecipients in Firebase Push Notification (FCM) 8
Same name and namespace in other branches
- 3.0.x src/Service/FirebaseMessageService.php \Drupal\firebase\Service\FirebaseMessageService::setRecipients()
Add single device, group of devices or multiple devices to message target.
Parameters
string|array $recipients: Recipients of message.
File
- src/
Service/ FirebaseMessageService.php, line 142
Class
- FirebaseMessageService
- Service for pushing message to mobile devices using Firebase.
Namespace
Drupal\firebase\ServiceCode
public function setRecipients($recipients) {
if (is_array($recipients)) {
if (count($recipients) < self::MAX_DEVICES) {
$this->body['registration_ids'] = $recipients;
}
else {
throw new \OutOfRangeException(sprintf('Message device limit exceeded. Firebase supports a maximum of %u devices.', self::MAX_DEVICES));
}
}
else {
$this->body['to'] = $recipients;
}
}