Warning
Version 3.2
introduce a BC break.
The signature of the __construct()
method of the Kerox\Fcm\Model\Message
class has changed, with the $notification
parameter becoming the third argument and being optional.
final class Message
{
- public Notification $notification;
+ public ?Notification $notification = null;
public ?string $token = null;
public ?string $topic = null;
public ?string $condition = null;
/**
* @param array<string, string> $data
*/
public function __construct(
- Notification|string $notification,
Token|Topic|Condition $target,
public array $data = [],
+ Notification|string|null $notification = null,
public ?AndroidConfig $android = null,
public ?WebpushConfig $webpush = null,
public ?ApnsConfig $apns = null,
public ?FcmOptions $fcmOptions = null,
) {
+ if (null !== $notification) {
$this->notification = \is_string($notification)
? new Notification($notification)
: $notification
;
+ }
match (true) {
$target instanceof Token => $this->token = $target->__toString(),
$target instanceof Topic => $this->topic = $target->__toString(),
$target instanceof Condition => $this->condition = $target->__toString(),
};
}
}
Before
$message = new Message(
notification: 'Breaking News',
target: new Topic('TopicA'),
data: [
'story_id' => 'story_12345',
],
);
After
$message = new Message(
target: new Topic('TopicA'),
data: [
'story_id' => 'story_12345',
],
notification: 'Breaking News',
);
What's Changed
Full Changelog: 3.1.0...3.2.0