Skip to content

Commit

Permalink
update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
prgayman committed Feb 19, 2021
1 parent 405493d commit be1a1c3
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,51 @@ $topicResponse = larafcm()
->send();
```

## Laravel Notification channel

```php

use Illuminate\Notifications\Notification;
use Prgayman\LaraFcm\Services\LaraFcm;

use Prgayman\LaraFcm\Message\Data;
use Prgayman\LaraFcm\Message\Notification as LaraFcmNotification;
use Prgayman\LaraFcm\Message\Options;

class SendPlacedOrder extends Notification
{
public function via($notifiable)
{
return ['larafcm'];
}

public function toLaraFcm($notifiable)
{
$tokens = ['TOKEN_1','TOKEN_2'];

return (new LaraFcm)
->notification(
(new LaraFcmNotification)
->setTitle('New Order')
->setBody('You have placed order')
->setColor('#f00')
)
->options(
(new Options)
->setTimeToLive(60*20)
->setContentAvailable(true)
)
->data(
(new Data)
->addData(['key'=>"value"])
)
->to($tokens)
->send();
}
}

```

## Licence

This library is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).
Expand Down

0 comments on commit be1a1c3

Please sign in to comment.