flutter_foreground_service_plugin icon indicating copy to clipboard operation
flutter_foreground_service_plugin copied to clipboard

Dynamically update notification content?

Open am2074 opened this issue 3 years ago • 0 comments

Is it possible to dynamically update the notification content property of FlutterForegroundPlugin.startForegroundService()?

For example:

var number = 0; 

void globalForegroundService() {
  number++;
}

void startForegroundService() async {
   await FlutterForegroundPlugin.setServiceMethodInterval(seconds:` 1);
   await FlutterForegroundPlugin.setServiceMethod(globalForegroundService);
   await FlutterForegroundPlugin.startForegroundService(
    holdWakeLock: false,
    onStarted: () {
      print("Foreground on Started");
    },
    onStopped: () {
      print("Foreground on Stopped");
    },
    title: "Flutter Foreground Service",
    content: number.toString(),
    iconName: "ic_stat_hot_tub",
  );
}

In the content session I would pass the number variable and the notification would reflect the changes each time the number is increased. So far I haven't had any luck with it.

am2074 avatar Jul 30 '21 19:07 am2074