paragraph1\phpFCM\Message::addRecipient PHP Method

addRecipient() public method

where should the message go
public addRecipient ( paragraph1\phpFCM\Recipient\Recipient $recipient ) : Message
$recipient paragraph1\phpFCM\Recipient\Recipient
return Message
    public function addRecipient(Recipient $recipient)
    {
        if (!$recipient instanceof Device && !$recipient instanceof Topic) {
            throw new \UnexpectedValueException('currently phpFCM only supports topic and single device messages');
        }
        if (!isset($this->recipientType)) {
            $this->recipientType = get_class($recipient);
        }
        if ($this->recipientType !== get_class($recipient)) {
            throw new \InvalidArgumentException('mixed recepient types are not supported by FCM');
        }
        $this->recipients[] = $recipient;
        return $this;
    }

Usage Example

Beispiel #1
0
 public function testProxyUriOverridesDefaultUrl()
 {
     $proxy = 'my_nice_proxy_around_that_server';
     $this->fixture->setProxyApiUrl($proxy);
     $guzzle = \Mockery::mock(\GuzzleHttp\Client::class);
     $guzzle->shouldReceive('post')->once()->with($proxy, \Mockery::any())->andReturn(\Mockery::mock(Response::class));
     $this->fixture->injectHttpClient($guzzle);
     $message = new Message();
     $message->addRecipient(new Topic('test'));
     $this->fixture->send($message);
 }