public function testReceivers() { $receiver = $this->getMockForAbstractClass(AbstractReceiver::class, [], '', false); $this->notification->addReceiver($receiver); self::assertCount(2, $this->notification->getReceivers()); $this->notification->clearReceivers(); self::assertCount(0, $this->notification->getReceivers()); }
/** * Get service formatted push messages. * * @param \Jgut\Tify\Notification $notification * * @throws \ZendService\Google\Exception\InvalidArgumentException * @throws \ZendService\Google\Exception\RuntimeException * * @return \Generator */ protected function getPushMessages(Notification $notification) { foreach (array_chunk($notification->getReceivers(), 100) as $receivers) { $tokens = array_map(function ($receiver) { return $receiver instanceof GcmReceiver ? $receiver->getToken() : null; }, $receivers); (yield $this->builder->buildPushMessage(array_filter($tokens), $notification)); } }
/** * 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)); } } }