capacitor-community / background-geolocation

A Capacitor plugin that sends you geolocation updates, even while the app is in the background.
MIT License
188 stars 57 forks source link

Android 12 Samsung device doesn't get precise location #57

Closed pdrhlik closed 2 years ago

pdrhlik commented 2 years ago

Describe the bug A user of my app told me that he has started experiencing very imprecise locations within hundreds of metres from his location. It seems as if he is not receiving locations from GPS.

To Reproduce A device with his specific configuration behaves this way. Other devices work flawlessly.

Expected behavior It should work on every device supported by Google Play services as of now.

Screenshots No screenshots.

Smartphone (please complete the following information):

Additional context What's interesting is that his wife has an Android 12 Samsung phone with One UI 4.0 and it's working perfectly. I guided him through app uninstallation, switching GPS settings to the most precise distance filter, disabling a power saver for the app but nothing has worked so far.

My app targets Android 11. It doesn't have an ACCESS_COARSE_LOCATION permission. I tried that, it worked on my phone with Android 11 but when I uploaded the app to Google Play, it said that it wouldn't support any devices at all. So I removed it again, it was still working and I was able to successfully upload it to Google Play without any issues.

Do you have any ideas what the issue might be? Let me know if you need any more info.

Patrik

diachedelic commented 2 years ago

The official docs say that the ACCESS_COARSE_LOCATION permission is always required: https://developer.android.com/training/location/permissions. I wonder why Google Play is refusing it?

diachedelic commented 2 years ago

Did you find a solution?

pdrhlik commented 2 years ago

Sorry for not replying sooner. I recently updated my phone to Android 12 as well, I have a completely different brand and it behaved exactly like that. I tried adding ACCESS_COARSE_LOCATION but that didn't solve the problem.

I observed that the problem is with precise location. All locations have accuracy around 2000 m. One of my users has found a workaround in android settings. Go to App settings -> Your app -> Location permissions. In Android 12, there is a new switch for precise location. The precise location was enabled but it didn't work. But when I turned it off and back on again, it started working as expected. That is, the issue is with the precise location permission.

diachedelic commented 2 years ago

I have a Samsung A52 which I recently upgraded to OneUI 4.0, and I have not been able to reproduce this problem. After upgrading to OneUI 4.1, I still can not reproduce it. The fact that turning precise locations off and on again fixed the problem for you indicates that there is a bug in the OS. If you can think of something this plugin can do to help, please let me know.

pdrhlik commented 2 years ago

It seems that I have finally figured out what the real problem was. I was mixing the @capacitor/geolocation plugin with this plugin to get a quicker coarse location. Unfortunately, some Android 12 phones didn't play well with this. I stopped getting the first location through @capacitor/geolocation and everything seems to be working now.

diachedelic commented 2 years ago

Thanks for clearing that up.