Firebase notification won`t sound or vibrate flutter
Solution 1
To enable sound on notification you need to add sound: default
part in notification data like this:
{
data: {
google.sent_time: 1588863942303,
click_action: FLUTTER_NOTIFICATION_CLICK,
google.original_priority: high,
collapse_key: YourPackageName,
google.delivered_priority: high,
sound: default,
from: YourSenderId,
google.message_id: 0:1588863942508709%a91ceea4a91ceea4,
google.ttl: 60
},
notification: {}
}
Solution 2
You can add something like this for the http request to send the notification.
But first thing you need to check is whether your phone is allowing the app to notify. which lost my most part of time.
{
topic: topic,
android: {
priority: "high",
notification: {
defaultSound: true,
//sound: "default",
},
},
data: {
somedata: "value",
},
notification: {
title: title,
body: description,
imageUrl: "https://i.picsum.photos/id/999/536/354.jpg?hmac=xYKikWHOVjOpBeVAsIlSzDv9J0UYTj_tNODJCKJsDo4",
},
}

Ricardo Oscar Kanitz
Updated on December 18, 2022Comments
-
Ricardo Oscar Kanitz 7 minutes
So I have enabled firebase messaging on my futter app everything works fine but, when I receive the notification in my app it wont sound or vibrate, neither android or ios. I believe FCM does it by default, I also have "IosNotificationSettings(sound: true, badge: true, alert: true)", but the notification just come mute. Do you guys have any Idea what could be happening? I searched for this situation but couldnt find anything about it. Thanks in advance for your help.
class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMixin { String _homeScreenText = "Waiting for token..."; final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); static const String contato = "contato"; TabController _tabController; @override void initState() { _tabController = new TabController(length: 5, vsync: this); super.initState(); _firebaseMessaging.configure( onMessage: (Map<String, dynamic> message) { print('on message $message'); }, onResume: (Map<String, dynamic> message) { print('on resume $message'); }, onLaunch: (Map<String, dynamic> message) { print('on launch $message'); }, ); _firebaseMessaging.requestNotificationPermissions( const IosNotificationSettings(sound: true, badge: true, alert: true)); _firebaseMessaging.onIosSettingsRegistered .listen((IosNotificationSettings settings) { print("Settings registered: $settings"); }); _firebaseMessaging.getToken().then((String token) { assert(token != null); setState(() { _homeScreenText = "Push Messaging token: $token"; }); print(_homeScreenText); }); _firebaseMessaging.getToken().then((token) { Firestore.instance.collection("pushtokens").document().setData({"devtoken": token}); }); }