laravel-notification-channels / fcm

Firebase Cloud Messaging (FCM) notifications channel for Laravel
https://laravel-notification-channels.com/
MIT License
495 stars 127 forks source link

Add macroable trait to FcmMessage class #145

Closed gdebrauwer closed 1 year ago

gdebrauwer commented 1 year ago

In all my fcm notifications, I create an FcmMessage object with the same AndroidConfig and ApnsConfig. It would be nice if I could create a macro that makes it possible to hide that shared code.

return FcmMessage::create()
    ->default() // macro that sets android and apns config
    ->...

// Instead of having to duplicate those configs in every notification
return FcmMessage::create()
    ->...
    ->setAndroid(
        AndroidConfig::create()->...
    )->setApns(
        ApnsConfig::create()->...
    );
dwightwatson commented 1 year ago

Nice one, thanks!