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); }
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()]); }