Flutter: Push notifications even if the app is closed

后端 未结 5 1218
长情又很酷
长情又很酷 2020-12-02 13:17

I have built an application with flutter that works like a reminder.
How can I display notifications to the user even though the app is closed?

5条回答
  •  情话喂你
    2020-12-02 13:59

    You can use scheduled notifications in flutter.

     var scheduledNotificationDateTime =
            new DateTime.now().add(new Duration(seconds: 5));
      var androidPlatformChannelSpecifics =
         new AndroidNotificationDetails('your other channel id',
        'your other channel name', 'your other channel description');
      var iOSPlatformChannelSpecifics =
       new IOSNotificationDetails();
       NotificationDetails platformChannelSpecifics = new 
      NotificationDetails(
       androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
      await flutterLocalNotificationsPlugin.schedule(
     0,
     'scheduled title',
     'scheduled body',
     scheduledNotificationDateTime,
     platformChannelSpecifics);
    

提交回复
热议问题