invertase / notifee

⚛️ A feature rich notifications library for React Native.
https://notifee.app
Apache License 2.0
1.88k stars 227 forks source link

isBatteryOptimizationEnabled returns true #1061

Open Willham12 opened 4 months ago

Willham12 commented 4 months ago

isBatteryOptimizationEnabled return true on Pixel 7 with Android 15 while background usage is enabled.

github-actions[bot] commented 3 months ago

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

Willham12 commented 3 months ago

Not fixed yet.

github-actions[bot] commented 2 months ago

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

Willham12 commented 2 months ago

Same issue on google pixel 8 with android 14

github-actions[bot] commented 1 month ago

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

Willham12 commented 1 month ago

Not fixed yet.

github-actions[bot] commented 3 weeks ago

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

Willham12 commented 3 weeks ago

Not fixed yet.

mikehardy commented 3 weeks ago

Unfortunately there are quite a few things much higher on the priority list and there are no more available magical fix gnomes wandering about looking for tasks Suggest you instrument the native APIs here if possible via patch-package to log as much information as possible about the native API call before it is made, and all information about the result after it returns, to get more insight into why it is failing

Willham12 commented 3 weeks ago

I would say that the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission is missing.

mikehardy commented 3 weeks ago

No permission is required to request the status.

That permission is only required to display an in-app dialog for users that allows direct disable of optimizations so not having that permission should have no relation to requesting the current optimization status. That action is strongly discouraged by Google in fact and can get your app banned. We don't use it, instead we use the gentler / does-not-get-app-banned ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS - and only if you want to try to alter the setting, not to request status

For status request we simply delegate to the power manager for this: https://github.com/search?q=repo%3Ainvertase%2Fnotifee+isBatteryOptimizationEnabled+language%3AJava&type=code&l=Java

It is a very simple API - a one-liner except the platform version check, no permission required

There have been (and according to comments on the closed issue) still are reports of this status not being maintained correctly in the operating system on multiple devices, so it seems to be an upstream issue: https://issuetracker.google.com/issues/37067894#comment14

Reports are that an app uninstall/reinstall will reset the status (not the most useful, but at least an indication that some change is detectable), does that happen in this case? https://stackoverflow.com/questions/50231908/powermanager-isignoringbatteryoptimizations-always-returns-true-even-if-is-remov

I don't think we're going to be able to fix this here unfortunately, though gathering information may result in a documentation update about why the status is potentially incorrect / not up to date