diff --git a/publish/publish.sh b/publish/publish.sh old mode 100644 new mode 100755 diff --git a/src/internal/tasks/schedulers/time-based/android/alarms/perm-request-common.ts b/src/internal/tasks/schedulers/time-based/android/alarms/perm-request-common.ts index 660bac4..78bef6f 100644 --- a/src/internal/tasks/schedulers/time-based/android/alarms/perm-request-common.ts +++ b/src/internal/tasks/schedulers/time-based/android/alarms/perm-request-common.ts @@ -17,3 +17,7 @@ export function waitForActivityResume(): Promise { ); }); } + +export function fireInMs(ms: number): Promise { + return new Promise((resolve) => setTimeout(resolve, ms)); +} diff --git a/src/internal/tasks/schedulers/time-based/android/alarms/power-savings-manager.android.ts b/src/internal/tasks/schedulers/time-based/android/alarms/power-savings-manager.android.ts index 3bb36c5..b464d46 100644 --- a/src/internal/tasks/schedulers/time-based/android/alarms/power-savings-manager.android.ts +++ b/src/internal/tasks/schedulers/time-based/android/alarms/power-savings-manager.android.ts @@ -1,7 +1,9 @@ import { Application, Utils } from "@nativescript/core"; import { createSavingsDeactivationIntent } from "../intents.android"; import { Logger, getLogger } from "../../../../../utils/logger"; -import { waitForActivityResume } from "./perm-request-common"; +import { fireInMs, waitForActivityResume } from "./perm-request-common"; + +const MS_TO_UPDATE = 1000; export class PowerSavingsManager { private logger: Logger; @@ -48,6 +50,9 @@ export class PowerSavingsManager { await activityResume; + // In certain phones the savings update is not immediate + await fireInMs(MS_TO_UPDATE); + if (!this.areDisabled()) { throw new Error( "Disabling battery optimizations is required for the app to work as expected!"