Home > Software engineering >  I created an android notification channel_id in Flutter, however, sending FCM to that channel does n
I created an android notification channel_id in Flutter, however, sending FCM to that channel does n

Time:10-16

I created an android notification channel by using the flutter_local_notification package with the following code:

await FlutterLocalNotificationsPlugin()
  .resolvePlatformSpecificImplementation<
      AndroidFlutterLocalNotificationsPlugin>()
  .createNotificationChannel(AndroidNotificationChannel(
    'high_importance_channel', // id
    'High Importance Notifications', // title
    description:
        'This channel is used for important notifications', // description
    importance: Importance.max,
  ));

When I request the current notification channels that my app use, I get the newly created (and a few others) back as a result, so the creation worked.

However, when I send a notification with FCM to the newly created channel, that notification does not make a sound or vibration. If I send the same notification to a channel that was already there, I do get a sound and vibration.

What am I doing wrong?

CodePudding user response:

another approach is to manually play sound and vibrate in onMessage/onBackgroundMessage/onBackgroundMessage using flutter_sound and flutter_vibrate

CodePudding user response:

It seems that the mistake is in the importance parameters.

importance: Importance.max

should be

importance: Importance.high

Importance.max is not used by Android, see here

  • Related