/**
  * @param Notification $notification
  * @param string       $deviceToken
  *
  * @return iOSMessage
  */
 protected function createMessage(Notification $notification, $deviceToken)
 {
     $pushNotification = new iOSMessage();
     $pushNotification->setMessage($notification->getMessage());
     $pushNotification->setDeviceIdentifier($deviceToken['token']);
     $pushNotification->setAPSSound('default');
     $pushNotification->setAPSBadge($deviceToken['badge']);
     /* @TODO send extra data to the client or not
        foreach ($notification->getContent() as $key => $value) {
            $pushNotification->addCustomData($key, $value);
        }
        */
     return $pushNotification;
 }
 /**
  * @param Notification $notification
  * @param string       $messageId
  */
 protected function processNotification(Notification $notification, $messageId)
 {
     $messageLog = sprintf('Process notification %s %s', $messageId, $notification->getMessage());
     $this->output->writeln($messageLog);
     $notification->setQueueId($messageId);
     $errors = $this->validator->validate($notification);
     if (count($errors) === 0) {
         $this->entityManager->persist($notification);
         $this->entityManager->flush();
         $this->output->writeln('Notification persisted');
         $this->notificationDispatcher->dispatchPushMessages($notification);
         $this->output->writeln('Notification dispatched');
     } else {
         $errorString = (string) $errors;
         $this->output->writeln('Notification validation error' . $errorString);
     }
 }