简体   繁体   中英

Flutter Local Notification only showing dot on Android

I am using Local Notifications for my app and it is working fine on my iPhone but when firing a Notification on my Android Simulator it is not showing the Notification on top of the screen but only the dot:

在此处输入图像描述

The Notification actually appears fine in the Notification Center:

在此处输入图像描述

I am making sure to init and I a calling instantNotification which looks like this:

  Future initialize() async {
    FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
        FlutterLocalNotificationsPlugin();

    AndroidInitializationSettings androidInitializationSettings =
        AndroidInitializationSettings('app_icon');

    IOSInitializationSettings iosInitializationSettings =
        IOSInitializationSettings();

    final InitializationSettings initializationSettings =
        InitializationSettings(
            android: androidInitializationSettings,
            iOS: iosInitializationSettings);

    await flutterLocalNotificationsPlugin.initialize(initializationSettings);
  }

  //Instant Notifications
  Future instantNofitication() async {
    var android = AndroidNotificationDetails('id', 'channel', 'description');

    var ios = IOSNotificationDetails();

    var platform = new NotificationDetails(android: android, iOS: ios);

    await _flutterLocalNotificationsPlugin.show(
      0,
      'Demo instant notification',
      'Tap to do something',
      platform,
      payload: 'Welcome to demo app',
    );
  }

What am I missing here?

You can try setting the importance level of the notification to a maximum with this line:

importance: Importance.max

which you add to the AndroidNotificationDetails class instance. This will tell to an Android OS that notification is important for the user and a heads-up display (a little popup) on top of the screen should be displayed for a few seconds.

I think that will solve your problem after reading an Android notification documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM