示例#1
0
 public function sendAndroid(Message $message)
 {
     // payload notification
     $notification = new GCMNotification($message->android->getTitle(), $message->android->getBody());
     $notification->setBodyLocKey($message->android->getBodyLocKey());
     $notification->setBodyLocArgs($message->android->getBodyLocArgs());
     $notification->setClickAction($message->android->getClickAction());
     $notification->setColor($message->android->getColor());
     $notification->setIcon($message->android->getIcon());
     $notification->setSound($message->android->getSound());
     $notification->setTag($message->android->getTag());
     $notification->setTitleLocKey($message->android->getTitleLocKey());
     $notification->setTitleLocArgs($message->android->getTitleLocArgs());
     $notification->setContentAvailable($message->android->isContentAvailable());
     // registration ids
     $_message = new GCMMessage($notification, $message->android->getTo());
     // options
     $_message->setCollapseKey($message->android->getCollapseKey());
     $_message->setDelayWhileIdle($message->android->getDelayWhileIdle());
     $_message->setDryRun($message->android->isDryRun());
     $_message->setRestrictedPackageName($message->android->getRestrictedPackageName());
     $_message->setTimeToLive($message->android->getTimeToLive());
     // payload data
     $_message->setData($message->android->getData());
     return $this->getAndroidClient()->send($_message);
 }
示例#2
0
 protected function generateJSONMessage(GCMMessage $message)
 {
     $data = array('registration_ids' => (array) $message->getTo(), 'notification' => $message->getNotification()->toArray(), 'data' => (array) $message->getData(), 'collapse_key' => $message->getCollapseKey(), 'delay_while_idle' => $message->getDelayWhileIdle(), 'time_to_live' => $message->getTimeToLive(), 'restricted_package_name' => $message->getRestrictedPackageName(), 'dry_run' => $message->getDryRun());
     return json_encode($data);
 }