I am developing a small android application in which I want to have Geolocation functionality. What I want to code is one service which gives the updated location of a user whether they are using my application or not.
I know that if I am continuously checking the user's location it will drain the battery of the device, so I want good solution for that. For example, to give me updates every 5 or 10 minutes. I have read about this question a lot but I wanted to get one good solution.
I read this page and it's a good solution if the user is using my application but if the user not using my application then what should I do? How do I solve this challenge?
In your app's manifest, check for the ACCESS_COARSE_LOCATION permission and the ACCESS_FINE_LOCATION permission. Verify that your app requires these location permissions. If your app targets Android 10 (API level 29) or higher, also check for the ACCESS_BACKGROUND_LOCATION permission.
In Android 9 and lower, an app can track a device's location while running in the background without the user's knowledge. Users can suppress this behavior in Android 10 by selecting either the Allow only while using the App or Deny location access permission.
Geolocation is enabled by default when you create a project with react-native init . In order to enable geolocation in the background, you need to include the 'NSLocationAlwaysUsageDescription' key in Info. plist and add location as a background mode in the 'Capabilities' tab in Xcode.
Previously i have developed such kind of application. with respect to your requirement, you will be require following APIs from Android.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With