You are here

private function PushNotificationsDispatcher::groupTokensByNetwork in Push Notifications 8

Group tokens by network.

Parameters

array $tokens_flat Array of token record objects.:

Return value

array $tokens Array of tokens grouped by network.

1 call to PushNotificationsDispatcher::groupTokensByNetwork()
PushNotificationsDispatcher::setTokens in src/PushNotificationsDispatcher.php

File

src/PushNotificationsDispatcher.php, line 111
Contains \Drupal\push_notifications\PushNotificationsDispatcher.

Class

PushNotificationsDispatcher
Handles dispatching of messages. This class will send out the message to all networks in the list of tokens.

Namespace

Drupal\push_notifications

Code

private function groupTokensByNetwork($tokens_flat = array()) {
  $tokens = array();
  foreach ($tokens_flat as $token) {
    switch ($token->network) {
      case PUSH_NOTIFICATIONS_NETWORK_ID_IOS:
        $tokens[PUSH_NOTIFICATIONS_NETWORK_ID_IOS][] = $token->token;
        break;
      case PUSH_NOTIFICATIONS_NETWORK_ID_ANDROID:
        $tokens[PUSH_NOTIFICATIONS_NETWORK_ID_ANDROID][] = $token->token;
        break;
    }
  }
  return $tokens;
}