juanamd / react-native-battery-whitelist

Check for manufacturer-specific opt-in battery optimization whitelists
MIT License
3 stars 2 forks source link

Error #1

Open rafalkowalewski opened 5 years ago

rafalkowalewski commented 5 years ago

Hello, I use Expokit and I would like to use you solution, but I got a problem, when I try to run your function :/ Null is not an object, and when I console log RNBatteryWhitelist it is null. Should I use react-native link? I was trying with and without this command and the result was the same. image

juanamd commented 5 years ago

Hi,

I've never used Expo so I wouldn't know if there is any specific requirements or caveats there. I've just tested this package in one of my projects and it works correctly. This project is using RN 0.60 so it works with the new auto-linking, but I know for a fact that it worked with previous versions of RN too.

If you are using RN < 0.60, you should indeed link the project. Be sure to check its added the needed lines to the following files since I've noticed when linking some other libraries, sometimes the "react-native link" command doesn't include all needed changes: -MainApplication.java -app/build.gradle -settings.gradle

rafalkowalewski commented 5 years ago

Hi,

I fixed the problem with "null is not an object", it was because of my mistake, so sorry for that. I am still using Expokit, and when i run your "hasWhitelistIntent" method, i get false, and the rest of script not execute :(

In adb logs i can find "No whitelist intent found" thrown from your function.

Any idea what is a problem?

My phone is Samsung with 9 system version.

Thanks for response :)

juanamd commented 5 years ago

That should only happen if the package doesn't detect any of the known battery-saving features in the device. For Samsung devices, it currently searches for:

"com.samsung.android.sm" "com.samsung.android.lool"

You can find the rest of these constants here.

I'll look if I can find any other of these constants that might be missing from the list.