Example #1
0
 public function testAlertPushMessage()
 {
     $receiver = new ApnsReceiver('9a4ecb987ef59c88b12035278b86f26d448835939a4ecb987ef59c88b1203527');
     $message = new Message(['title-loc-key' => 'MESSAGE_TITLE']);
     $notification = new Notification($message, [$receiver]);
     $pushMessage = $this->builder->buildPushMessage($receiver, $notification);
     self::assertInstanceOf(ApnsMessage::class, $pushMessage);
     self::assertEquals('MESSAGE_TITLE', $pushMessage->getAlert()->getTitleLocKey());
 }
Example #2
0
 /**
  * Get service formatted push messages.
  *
  * @param \Jgut\Tify\Notification $notification
  *
  * @throws \ZendService\Apple\Exception\RuntimeException
  *
  * @return \Generator
  */
 protected function getPushMessages(Notification $notification)
 {
     foreach ($notification->getReceivers() as $receiver) {
         if ($receiver instanceof ApnsReceiver) {
             (yield $this->builder->buildPushMessage($receiver, $notification));
         }
     }
 }