You are here

public function FirebaseTopicManagerService::processTopicSubscription in Firebase Push Notification (FCM) 3.0.x

Same name and namespace in other branches
  1. 8 src/Service/FirebaseTopicManagerService.php \Drupal\firebase\Service\FirebaseTopicManagerService::processTopicSubscription()

Process topic un/subscription.

Parameters

string $topic: The topic, which will be processed.

string|array $tokens: Token or tokens this will be subscriber\unsubscribe by topic.

string $endpoint: The endpoint for processing by topic.

File

src/Service/FirebaseTopicManagerService.php, line 43

Class

FirebaseTopicManagerService
Service for managing topics.

Namespace

Drupal\firebase\Service

Code

public function processTopicSubscription($topic, $tokens, $endpoint) {
  $this->endpoint = $endpoint;
  $this->body = [
    'to' => '/topics/' . $topic,
    'registration_tokens' => is_array($tokens) ? $tokens : [
      $tokens,
    ],
  ];
  $this
    ->send();
}