public function PushNotificationsTokenQuery::getTokensByNetwork in Push Notifications 8
Get the push notification tokens by network.
Parameters
array $networks: Push Networks.
Return value
array|null
File
- src/
PushNotificationsTokenQuery.php, line 78 - Contains Drupal\push_notifications\PushNotificationsTokenQuery.
Class
Namespace
Drupal\push_notificationsCode
public function getTokensByNetwork($networks) {
if (!is_array($networks)) {
return NULL;
}
$push_notifications_token_storage = $this->entityManager
->getStorage('push_notifications_token');
$push_notifications_token = $push_notifications_token_storage
->loadByProperties(array(
'network' => $networks,
));
// Retrieve all tokens into array.
$tokens = array();
foreach ($push_notifications_token as $pid => $push_notification_token) {
array_push($tokens, $push_notification_token
->getToken());
}
return $tokens;
}