appIsForeground method
Whether the app is in the foreground. Answered authoritatively on iOS
(UIApplication.applicationState), where a VoIP push can launch the app in
the BACKGROUND and no permission dialog can be presented. Defaults to true
where unimplemented, preserving the caller's normal behaviour.
Implementation
@override
Future<bool> appIsForeground() async {
try {
return await methodChannel.invokeMethod<bool>('appIsForeground') ?? true;
} catch (_) {
return true; // unimplemented on this platform — assume foreground
}
}