应用被杀死后,本地通知无法正常工作

时间:2019-05-19 05:37:19

标签: dart flutter mobile-application localnotification

我正在创建一个应用程序,该应用程序需要每隔一小时向用户发送一次通知,以便我使用了扑朔迷离的本地通知,该应用程序在运行时运行良好(如果该应用程序被杀死,则该通知将无法获得帮助)我出来的家伙....在此先感谢!

showNotification() async {
   var android = new AndroidNotificationDetails(
    "channelId", "channelName", "channelDescription");
   var ios = new IOSNotificationDetails();
   var platform = new NotificationDetails(android, ios);
   await flutterLocalNotificationsPlugin.show(
       0, "It's time to drink", "Be Hydrate", platform);
 }


   @override
   void initState() {
   super.initState();
   flutterLocalNotificationsPlugin = new 
   FlutterLocalNotificationsPlugin();
   var android = new 
   AndroidInitializationSettings('@mipmap/ic_launcher');
   var ios = new IOSInitializationSettings();
   var initsetting = new InitializationSettings(android, ios);
   flutterLocalNotificationsPlugin.initialize(initsetting,
      onSelectNotification: onSelectNotification);
  }



       Future.delayed(Duration(hour: 1), () {
        showNotification();
         });

0 个答案:

没有答案