Skip to content

Commit

Permalink
fix: Improve foreground service init and disable
Browse files Browse the repository at this point in the history
  • Loading branch information
ponces committed Sep 19, 2022
1 parent 9405334 commit 269a71d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/ui/views/installer/installer_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class InstallerViewModel extends BaseViewModel {
Future<void> initialize(BuildContext context) async {
if (await Permission.ignoreBatteryOptimizations.isGranted) {
try {
await FlutterBackground.initialize(
FlutterBackground.initialize(
androidConfig: FlutterBackgroundAndroidConfig(
notificationTitle: FlutterI18n.translate(
context,
Expand All @@ -49,8 +49,7 @@ class InstallerViewModel extends BaseViewModel {
defType: 'drawable',
),
),
);
await FlutterBackground.enableBackgroundExecution();
).then((value) => FlutterBackground.enableBackgroundExecution());
} on Exception {
// ignore
}
Expand Down Expand Up @@ -123,9 +122,9 @@ class InstallerViewModel extends BaseViewModel {
hasErrors = true;
update(-1.0, 'Aborting...', 'No app or patches selected! Aborting');
}
if (await Permission.ignoreBatteryOptimizations.isGranted) {
if (FlutterBackground.isBackgroundExecutionEnabled) {
try {
await FlutterBackground.disableBackgroundExecution();
FlutterBackground.disableBackgroundExecution();
} on Exception {
// ignore
}
Expand Down

0 comments on commit 269a71d

Please sign in to comment.