예제 #1
0
 public function testMutatorsAccessors()
 {
     self::assertCount(0, $this->message->getNotificationPayload());
     $this->message->addNotificationPayload('first', 'first');
     self::assertCount(1, $this->message->getNotificationPayload());
     $this->message->setNotificationPayload(['first' => 'first', 'second' => 'second']);
     self::assertCount(2, $this->message->getNotificationPayload());
     $this->message->clearNotificationPayload();
     self::assertCount(0, $this->message->getNotificationPayload());
 }
예제 #2
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;
 }