Example #1
0
 /**
  * Get configured service message.
  *
  * @param array                   $tokens
  * @param \Jgut\Tify\Notification $notification
  *
  * @throws \ZendService\Google\Exception\InvalidArgumentException
  * @throws \ZendService\Google\Exception\RuntimeException
  *
  * @return \Jgut\Tify\Adapter\Gcm\GcmMessage
  */
 public function buildPushMessage(array $tokens, Notification $notification)
 {
     $message = $notification->getMessage();
     $pushMessage = new GcmMessage();
     $pushMessage->setRegistrationIds($tokens)->setCollapseKey($notification->getParameter('collapse_key'))->setDelayWhileIdle($notification->getParameter('delay_while_idle'))->setTimeToLive($notification->getParameter('time_to_live'))->setRestrictedPackageName($notification->getParameter('restricted_package_name'))->setDryRun($notification->getParameter('dry_run'))->setData($message->getPayloadData());
     if ($this->shouldHaveNotification($message)) {
         $pushMessage->setNotificationPayload($message->getParameters());
     }
     return $pushMessage;
 }
Example #2
0
 public function testJsonResult()
 {
     $this->message->setRegistrationIds(['sdfshj']);
     $this->message->setCollapseKey('key');
     $this->message->setDelayWhileIdle(true);
     $this->message->setTimeToLive(600);
     $this->message->setRestrictedPackageName('package.name');
     $this->message->setDryRun(true);
     $this->message->setData(['key' => 'value']);
     $this->message->addNotificationPayload('first', 'first');
     $result = json_decode($this->message->toJson());
     self::assertTrue(isset($result->notification->first));
 }