I noticed that the flutter firebase_messaging package automatically handles push notifications for the device. But is there any way to programmatically enable or disable the notification sound and vibration? I would like to provide a switch box in my app settings where the user can choose whether they want the device to make the sound and/or vibrate when a notification arrives.
Asked
Active
Viewed 1,540 times
1 Answers
-1
You can store the users preferences in a database and then check their preferences before pushing the notification. If the user prefer to get notified with sound and vibration implement "sound": "default"
when building your notification. If, on the contrary, they do not prefer sound and vibration you can omit the attribute and the notification will arrive silently. Look at this SO post for a reference of how to structure the data.

flarkmarup
- 5,129
- 3
- 24
- 25
-
The notification doesn't arrive silently when I omit the "sound" attribute. It uses the system default sound instead. So I'm trying to use an mp3 file with no sound(silence) but it seems that it doesn't find the sound file if I place it in my assets folder and add it as a dependency to pubspec.yaml. Any idea where I should place it? – Dastan Jun 18 '19 at 01:57