Exemplo n.º 1
0
 public function checkPayload(PHPush\Message $message)
 {
     $payload = json_encode($message->getMessage());
     if (mb_strlen($payload) > 250) {
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 public function sendMessage(PHPush\Message $message)
 {
     $headers = array('Authorization: key=' . $this->googleApiKey, 'Content-Type: application/json');
     $gcmData = $message->getMessage()->toArray();
     if (isset($this->timeToLive)) {
         $gcmData['time_to_live'] = $this->timeToLive;
     }
     if (isset($this->restrictedPackageName)) {
         $gcmData['restricted_package_name'] = $this->restrictedPackageName;
     }
     if (is_array($this->deviceToken)) {
         $parameters = array('registration_ids' => $this->deviceToken);
     } else {
         $parameters = array('to' => $this->deviceToken);
     }
     $parameters = array_merge($parameters, $gcmData);
     return $this->execute($parameters, $headers);
 }