示例#1
0
文件: Sender.php 项目: lukyrys/gcm
 protected function getPayload(Message $message)
 {
     $data = array('registration_ids' => (array) $message->getTo(), 'collapse_key' => $message->getCollapseKey(), 'data' => (array) $message->getData(), 'delay_while_idle' => $message->getDelayWhileIdle(), 'time_to_live' => $message->getTimeToLive(), 'restricted_package_name' => $message->getRestrictedPackageName(), 'dry_run' => $message->getDryRun());
     return json_encode($data);
 }
示例#2
0
文件: Daemon.php 项目: petrsladek/gcm
 public function send(Message $message)
 {
     if (count($message->getTo()) == 0) {
         throw new NotRecipientException("Recipient must set use");
     }
     if (count($message->getTo()) > 1) {
         throw new TooManyRecipientsException("Recipient must by only one");
     }
     $this->sendGcmMessage(['to' => $message->getTo(true), 'collapse_key' => $message->getCollapseKey(), 'time_to_live' => $message->getTimeToLive(), 'delay_while_idle' => $message->getDelayWhileIdle(), 'message_id' => (string) microtime(), 'data' => $message->getData()]);
 }