Replies: 1 comment 2 replies
-
You can add platform-specific configuration (Android, iOS, Web) with use Kreait\Firebase\Messaging\AndroidConfig;
// Example from https://firebase.google.com/docs/cloud-messaging/admin/send-messages#android_specific_fields
$config = AndroidConfig::fromArray([
'ttl' => '3600s',
'priority' => 'normal',
'notification' => [
'title' => '$GOOG up 1.43% on the day',
'body' => '$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.',
'icon' => 'stock_ticker_update',
'color' => '#f45342',
'sound' => 'default',
],
]);
$message = $message->withAndroidConfig($config); or directly with $message = CloudMessage::fromArray([
'notification' => [
'title' => 'Generic title',
'body' => 'Generic body',
],
'android' => [
'ttl' => '3600s',
'priority' => 'normal',
'notification' => [
'title' => 'Android-specific title',
'body' => 'Android-specific body',
],
],
]); With both ways, you can add any configuration that is supported by Firebase (current and future fields). (In fact, I would say today that using an array instead of the builder classes should be the recommended way, and I'm probably going to make this the recommended default and remove the other ways in the next major release, but that's just a side note) Concerning the decision to make most of the classes I know this is a controversial topic and many wars have been fought about it on Twitter and Reddit, but here, this is how I roll 😅. I hope this helps, sorry if it was too much bla bla! PS: You don't need to notify me in an additional email that you asked a question, I get notified about anything that happens in my open-source projects and I usually react in a timely manner - 😅 |
Beta Was this translation helpful? Give feedback.
-
Hi Jérôme Gamez,
Firstly, thanks for creating this awesome package.
There is a specific kind of notification in firebase named AndroidNotification:
https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidnotification
I checked the package and figured out that it doesn't have such a notification class.
So I decided to extend the main Notification class and make a PR.
But when I checked the Notifications class, I noticed that it is "final".
What is the reason behind making this class final?
Regards
Beta Was this translation helpful? Give feedback.
All reactions