Ejemplo n.º 1
0
 public function test()
 {
     $device = $this->getDevice();
     $pushToken = PushToken::find((int) $device->id);
     if ($pushToken) {
         Push::send($pushToken->platform, $pushToken->token, 'This is test message');
         return $this->respondNoContent();
     } else {
         return $this->respondWithError('Device isn\'t bound');
     }
 }
Ejemplo n.º 2
0
 public function send()
 {
     $this->data['new']['chats'] = array_values(array_unique($this->data['new']['chats']));
     $this->data['new']['posts'] = array_values(array_unique($this->data['new']['posts']));
     $this->data['new']['comments'] = array_values(array_unique($this->data['new']['comments']));
     $this->data['new']['carChats'] = array_values(array_unique($this->data['new']['carChats']));
     $this->data['new']['emergencies'] = array_values(array_unique($this->data['new']['emergencies']));
     if (isset($this->data['posts'])) {
         $posts = array();
         foreach ($this->data['posts'] as $post) {
             if (isset($post['comments'])) {
                 $comments = array();
                 foreach ($post['comments'] as $comment) {
                     $comments[] = $comment;
                 }
                 $post['comments'] = $comments;
             }
             $posts[] = $post;
         }
         $this->data['posts'] = $posts;
     }
     if (isset($this->data['comments'])) {
         $comments = array();
         foreach ($this->data['commented'] as $comment) {
             $comments[] = $comment;
         }
         $this->data['comments'] = $comments;
     }
     $this->redis->set($this->token, json_encode(array('new' => $this->data['new'])));
     $json = json_encode($this->data);
     $this->redis->publish($this->token, $json);
     $device = Device::where('auth_token', $this->token)->first();
     $pushToken = PushToken::find((int) $device->id);
     if ($pushToken) {
         Push::send($pushToken->platform, $pushToken->token, $json);
     }
     return $this;
 }