-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change method to prompt for ignoring background optimization #980
Comments
In the android project, the permission needs to be added to The changes to So after you have made the changes under In the plugin, the permission changes will go into think of this as a library |
|
Implemented the new There is a bug that arises, however, where when you click "Fix" and get the prompt for allowing the aforementioned, it won't let you "fix" any other permissions that bring you to the settings. It appears that the battery optimization prompts the user on the app, but also creates a pop up in the settings which is irresponsive that you can't click on. If you close that settings tab then you're allowed to "fix" other permissions as it lets you actually go to the settings now. It's definitely a weird bug that I'll have to look deeper into, just wanted to get it out for now. |
@louisg1337 this is the popup we want to get - see #934 (comment) Can you clarify what you mean by " but also creates a pop up in the settings which is irresponsive that you can't click on.". Maybe a video that will show us the unreponsiveness. @JGreenlee since he has seen this popup on other apps with background operation and has a sense of what is supposed to happen. |
Looks like great progress! It's the right popup but it's apparently launching over a Settings activity when it should just launch within our app activity. I would double check the intent and make sure it is not still trying to launch the "battery optimizations" page. |
Apparently |
It would also be helpful to show us your changes - maybe start a draft PR in |
Thank you guys for getting back to me with the feedback! Firstly, I created a draft pr here. I also added in a video below which should show the bug better I hope. In terms of your guys' suggestions, I used bug.webm |
@louisg1337 per our conversation today:
|
Slight update as I want to get my findings out before I go for the night. I tried using permission checker but I couldn't seem to get it to work with If the permission checker method is not imperative, I did seem to fix the bug in the original code. If you use |
@louisg1337 I think it would be better to use the permission checker if possible since (i) it is a single location for popups, and (ii) it also deals with complex logic around people hitting "deny", instead of "allow", which you may not have tested. For example, you always call I checked the PR and you have permission checker code largely working correctly. The status constant is correct (I assume you will put the hardcoded value into Note that this process is asynchronous - android generates a popup, waits for the user to respond, and then calls back with the status constant and that is when we need to return |
|
I managed to get the code working now using I pushed my changes to the draft PR. The commit does look confusing as it makes it seem like I rewrote the whole file, but it was just me trying to re-style the file back to its original state as I put in a bunch of spaces and comments to help me navigate the file. The main changes I made were in I do still have to test it on <= Q devices, although whenever I try to get onto the Google Play Store on a Q emulator to update Webview it won't let me and says authentication failed. Now whenever I try to load into it it refuses to take my phone number as a verification because it "has been used too many times." Screen.Recording.2023-09-27.at.10.55.34.PM.mov |
@louisg1337 During the onboarding process, we currently ask participants to give us a bunch of permissions.
On android, this includes the permission to remove background optimizations using
#934 (comment)
However, this is a bad user experience since
ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS
essentially launches a new screen with the currently unoptimized apps. The user has to select "optimized" and then search for the app name and then select "turn off optimization".@JGreenlee found that other apps use a popup
#934 (comment)
by replacing the call with one to
ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
insteadHowever, this requires an additional permission
#934 (comment)
but there is some evidence that this may increase the chance of the app being rejected
#934 (comment)
We want to update the
checkAndPromptIgnoreBatteryOptimizations
insrc/android/verification/SensorControlForegroundDelegate.java
in the e-mission-data-collection pluginhttps://github.com/e-mission/e-mission-data-collection to use
ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
instead ofACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS
Note that https://github.com/e-mission/e-mission-data-collection is a cordova plugin, so after you make the change you will need to remove + re-add it (
cordova plugin rm
andcordova plugin add
) so that you can test it with the UI.The text was updated successfully, but these errors were encountered: