Make sure alarms aren't on with app being optimized

If battery optimizations are on for the app,
alarms will have several unpredictable bugs.
For example, sometimes sounds won't play,
sometimes re focuisng the app won't work.
This commit is contained in:
Brandon Presley 2022-12-28 14:56:29 +13:00
parent 2c6a773548
commit d6e7d6158c
1 changed files with 5 additions and 2 deletions

View File

@ -58,9 +58,12 @@ export default function SettingsPage() {
setDate(settings.date)
setShowDate(settings.showDate)
setNoSound(settings.noSound)
if (Platform.OS !== 'android') return
NativeModules.SettingsModule.ignoringBattery((isIgnoring: boolean) => {
if (!isIgnoring && settings.alarm) setAlarm(false)
setIgnoring(isIgnoring)
})
})
if (Platform.OS !== 'android') return
NativeModules.SettingsModule.ignoringBattery(setIgnoring)
NativeModules.SettingsModule.is24().then((is24: boolean) => {
console.log(`${SettingsPage.name}.focus:`, {is24})
if (is24) setFormatOptions(['P', 'P, k:m', 'ccc k:m', 'k:m'])