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 providerRejects($id)
 {
     if ($this->isClosed()) {
         return false;
     }
     $key = array_search($id, $this->providers);
     if ($key !== false) {
         unset($this->providers[$key]);
         if (!$this->save()) {
             return false;
         }
         if (count($this->providers) == 0) {
             $user = User::findById((string) $this->user);
             Push::send('Não foram encontradas pessoas disponíveis.', [$user->registrationId]);
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
 /**
  * handle incoming events
  *
  */
 public static function event($params)
 {
     // send a push notification
     Push::send($params['subject'] . ' ' . $params['message'] . ' ' . $params['file'], $params['link']);
 }
Ejemplo n.º 4
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;
 }