LaravelFCM\Message\Topics::topic PHP Method

topic() public method

Add a topic, this method should be called before any conditional topic
public topic ( string $first )
$first string topicName
    public function topic($first)
    {
        $this->conditions[] = compact('first');
        return $this;
    }

Usage Example

Example #1
0
 /**
  * @test
  */
 public function it_send_a_notification_to_a_topic_and_return_error()
 {
     $response = new Response(200, [], '{"error":"TopicsMessageRateExceeded"}');
     $client = Mockery::mock(Client::class);
     $client->shouldReceive('post')->once()->andReturn($response);
     $fcm = new FCMSender($client, 'http://test.test');
     $topics = new Topics();
     $topics->topic('test');
     $response = $fcm->sendToTopic($topics);
     $this->assertFalse($response->isSuccess());
     $this->assertTrue($response->shouldRetry());
     $this->assertEquals('TopicsMessageRateExceeded', $response->error());
 }