public function sendNotify(Message $message, RedmineUser $user)
 {
     if ($user->getDevices()->count()) {
         /** @var Device $device */
         foreach ($user->getDevices() as $device) {
             if ($device->isEnabled()) {
                 $logMessage = 'platform not found';
                 $logCustom = 'custom';
                 if ($device->getPlatform() === self::PLATFORM_ANDROID) {
                     $logMessage = $message->getGcmData();
                     $logCustom = $message->getCustom();
                 }
                 if ($device->getPlatform() === self::PLATFORM_IOS) {
                     $logMessage = $message->getApnsData();
                     $logCustom = $message->getCustom();
                 }
                 if ($device->getPlatform() === self::PLATFORM_IOS_SB) {
                     $logMessage = $message->getApnsData();
                     $logCustom = $message->getCustom();
                 }
                 try {
                     $this->messages->send($message, $device->getArn());
                     $this->logger->info("\nSend message to: ", ['DEVICE' => $device->toLog(), 'MESSAGE' => $logMessage, 'CUSTOM' => $logCustom]);
                 } catch (\Exception $e) {
                     $device->setEnabled(false);
                     $this->em->flush();
                     $this->logger->critical("\n Device is disabled: ", ['DeviceArn: ' => $device->getArn()]);
                 }
             }
             if (!$device->isEnabled()) {
                 $newDevice = $this->getDevice($device->getUser(), $device->getDeviceId(), $device->getPushtoken(), $device->getPlatform());
                 $logMessage = 'platform not found';
                 $logCustom = 'custom';
                 if ($device->getPlatform() === self::PLATFORM_ANDROID) {
                     $logMessage = $message->getGcmData();
                     $logCustom = $message->getCustom();
                 }
                 if ($device->getPlatform() === self::PLATFORM_IOS) {
                     $logMessage = $message->getApnsData();
                     $logCustom = $message->getCustom();
                 }
                 if ($device->getPlatform() === self::PLATFORM_IOS_SB) {
                     $logMessage = $message->getApnsData();
                     $logCustom = $message->getCustom();
                 }
                 try {
                     $this->messages->send($message, $newDevice->getArn());
                     $this->logger->info("\nSend message to: ", ['DEVICE' => $device->toLog(), 'MESSAGE' => $logMessage, 'CUSTOM' => $logCustom]);
                 } catch (\Exception $e) {
                     $device->setEnabled(false);
                     $this->em->flush();
                     $this->logger->critical("\n Device is disabled: ", ['DeviceArn: ' => $device->getArn()]);
                 }
             }
         }
         //  end foreach devices
     }
 }
 private function sendPush(RedmineUser $user, $message)
 {
     $message = new Message($message);
     $message->setTtl(86400);
     $message->setBadge(0);
     /** @var Device $device */
     foreach ($user->getDevices() as $device) {
         try {
             $this->messages->send($message, $device->getArn());
         } catch (\Exception $e) {
             $device->setEnabled(false);
             $this->em->flush();
         }
     }
 }