didChangeAppLifecycleState method

  1. @override
void didChangeAppLifecycleState(
  1. AppLifecycleState state
)
override

Called when the system puts the app in the background or returns the app to the foreground.

An example of implementing this method is provided in the class-level documentation for the WidgetsBindingObserver class.

This method exposes notifications from SystemChannels.lifecycle.

See also:

Implementation

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
  // On resume, let the shared session rotate if it has gone idle past the
  // timeout — so both analytics grouping and session-scoped frequency caps
  // see a fresh session. Owned here (the SDK's lifecycle observer), not in
  // analytics.
  if (state == AppLifecycleState.resumed) {
    SessionManager.instance.maybeExpire();
  }
  // detached = permanent process destruction. Not paused (every background).
  DigiaAnalyticsService.instance.appLifecycleChanged(state);
  if (state == AppLifecycleState.detached) {
    _activePlugin?.teardown();
    _activePlugin = null;
  }
}