getAppLifeCycle method
Returns the current state of the app lifecycle in regards to notifications.
The returned value is an enumerator of type NotificationLifeCycle. The possible values are:
-
NotificationLifeCycle.Foreground: The app is currently in the foreground and actively being used by the user.
-
NotificationLifeCycle.Background: The app is currently in the background and not actively being used by the user, but still running.
-
NotificationLifeCycle.AppKilled: The app has been killed and is not running.
This method returns a Future that resolves to a NotificationLifeCycle value representing the current state of the app in regards to notifications.
Implementation
@override
Future<NotificationLifeCycle> getAppLifeCycle() async {
final String? lifeCycleRaw =
await methodChannel.invokeMethod(CHANNEL_METHOD_GET_APP_LIFE_CYCLE);
return NotificationLifeCycle.values
.firstWhere((e) => e.name == lifeCycleRaw);
}