Пример #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();
     }
 }
Пример #2
0
 /**
  * Set the device tokens.
  * 
  * @param mixed $device
  *
  * @return \Jenky\LaravelNotification\Providers\Mobile
  */
 public function device($device)
 {
     if (is_array($device)) {
         $devices = [];
         foreach ($device as $_device) {
             $devices[] = $this->push->Device($_device['token'], $_device['options']);
         }
         return $this->push->DeviceCollection($devices);
     }
     return;
 }