Skip to content

v3.2.0

Latest
Compare
Choose a tag to compare
@ker0x ker0x released this 15 Feb 09:42
3a2449e

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

  • 🐛 Allow to send message with data only by @ker0x in #27

Full Changelog: 3.1.0...3.2.0