laravel-notification-channels / fcm

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

Add more specific parameter type for `setData()` method #114

Closed maximal closed 2 years ago

maximal commented 2 years ago

FCM message will not be received if array shape is different from array<string, string> (string keys and string values).

For example, this code won’t work:

return FcmMessage::create()
    ->setData([
        'string_key1' => 'string_value1',
        'string_key2' => 'string_value1',
        'string_key3' => 666, // integer value
    ])->...

I propose to specify an array shape for the parameter of setData() method in order to help IDEs to analyse the code and to highlight possible errors preemptively. This will save developers’ time (I personally spent on this issue a couple of investigation hours).