Skip to content

Commit

Permalink
Add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
dwightwatson committed Oct 28, 2023
1 parent 111f2c1 commit c60af3e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
56 changes: 54 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,58 @@

All notable changes will be documented in this file

## 1.0.0 - 201X-XX-XX
## 4.0.0 - 2023-10-28

- initial release
This version is a pretty substantial rewrite that removes a lot of complexity from the library, makes some features more consistent and increases test coverage.

* Requires PHP 8.2+, and Laravel 10.x,
* The constructor for `FcmMessage` and `FcmNotification` have changed to use named arguments,
* The custom resource objects have been removed,
* The ability to use a custom client has been standardised.

### Re-write your message

Many of the `set*` methods have been removed and replaced with public properties. The basics you can still use with ease - setting the properties of an `FcmNotification` and setting additional data. If you want to set more explicit options (iOS or Android configuration for example) you will use the `custom` method.

```php
return new FcmMessage(notification: new FcmNotification(
title: 'Account Activated',
body: 'Your account has been activated.',
image: 'http://example.com/url-to-image-here.png'
))
->data(['data1' => 'value', 'data2' => 'value2'])
->custom([
'android' => [
'notification' => [
'color' => '#0A0A0A',
],
'fcm_options' => [
'analytics_label' => 'analytics',
],
],
'apns' => [
'fcm_options' => [
'analytics_label' => 'analytics',
],
],
]);
```

### Use a custom client

The way to change the FCM configuration on the fly now requires passing in an instance of `Kreait\Firebase\Contract\Messaging`. Set it up with your credentials and pass it into a message with `usingClient`.

```php
public function toFcm(mixed $notifiable)
{
$client = app(\Kreait\Firebase\Contract\Messaging::class);

return FcmMessage::create()->usingClient($client);
}
```

### Handling failures

Listen to the `Illuminate\Notifications\Events\NotificationFailed` event which will include each individual failure for report you to handle as you need.

Please re-review the documentation when upgrading to the latest version and make the changes necessary for your app.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class AccountActivated extends Notification
return [FcmChannel::class];
}

public function toFcm($notifiable)
public function toFcm($notifiable): FcmMessage
{
return (new FcmMessage(notification: new FcmNotification(
title: 'Account Activated',
Expand Down Expand Up @@ -153,7 +153,7 @@ FcmMessage::create()
You can change the underlying Firebase Messaging client on the fly if required. Provide an instance of `Kreait\Firebase\Contract\Messaging` to your FCM message and it will be used in place of the default client.

```php
public function toFcm(mixed $notifiable)
public function toFcm(mixed $notifiable): FcmMessage
{
$client = app(\Kreait\Firebase\Contract\Messaging::class);

Expand Down

0 comments on commit c60af3e

Please sign in to comment.