Ejemplo n.º 1
0
 /**
  * @param User $user
  * @param Message $message
  * @param bool $sms_immediately
  */
 public function send(User $user, Message $message, $sms_immediately = false)
 {
     $config = config('pusher');
     if (count($user->getAndroidDeviceId()) > 0) {
         foreach ($user->getAndroidDeviceId() as $androidDeviceId) {
             $this->pushNotification->app('android')->to($androidDeviceId)->send('', array_merge(['msg' => $message->getPushMessage()], $message->getPushMessageOptionAsAndroidFormat()));
         }
     }
     if (count($user->getIosDeviceId()) > 0) {
         foreach ($user->getIosDeviceId() as $iosDeviceId) {
             $this->pushNotification->app('ios')->to($iosDeviceId)->send($message->getPushMessage(), $message->getPushMessageOptionAsIosFormat());
         }
     }
     // 핸드폰번호가 세팅되어있으면 문자보내기 큐에다 저장
     if ($user->getHp()) {
         $schedule = new $config['schedule']();
         $timeOffset = config('pusher.sms_after');
         if ($sms_immediately) {
             $timeOffset = 0;
         }
         $schedule->hp = $user->getHp();
         $schedule->content = $message->getSmsMessage();
         $schedule->unique_key = $message->getUniqueKey();
         $schedule->sending_at = Carbon::now()->addMinutes($timeOffset)->format('Y-m-d H:i:00');
         $schedule->save();
     }
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function send()
 {
     $to = is_array($this->to) ? $this->device($this->to) : $this->to;
     return $this->push->app($this->appConfig)->to($to)->send($this->message);
 }