run method
the SimpleFrameApp subclass implements application-specific code
Implementation
@override
Future<void> run() async {
_log.info("start listening");
var hasPermission = (await NotificationsListener.hasPermission)!;
_log.info("permission: $hasPermission");
if (!hasPermission) {
_log.info("no permission, so open settings");
NotificationsListener.openPermissionSettings();
} else {
_log.info("has permission, so open settings anyway");
// TODO seems not to update hasPermission to false after stopService
// TODO Occasionally the permission disappears from both approved and denied lists in the UI...?
// so force an openPermissionSettings on startListening every time
NotificationsListener.openPermissionSettings();
}
var isRunning = (await NotificationsListener.isRunning)!;
_log.info("running: $isRunning");
if (!isRunning) {
_log.info("not running: starting service");
await NotificationsListener.startService(foreground: false);
}
setState(() {
currentState = ApplicationState.running;
});
}