Closed valery-lavrik closed 10 months ago
any ideas how to fix the problem?
I edited the file you suggested to change in your PR #254 but it still doesn't work when the app is not focused (Location request timed out).
I don't directly use headless-js-android but I use react-native-background-actions which relies on it.
With all the permissions checked I launch a background task that chronically check for geolocalisation, but as soon as I leave my app in background I can't collect it.
I use this option set: enableHighAccuracy: true, timeout: 20000, maximumAge: 10000,
Do you have any clue on that problem ?
Everything worked for me. To do this, I made my own fork https://github.com/valery-lavrik/react-native-geolocation
But, in order for everything to work properly, I had to: 1) enable autorun of the application in the android settings (my application should start itself after reboot) 2) for my application, in the android settings you need to specify "allow access to geolocation in any mode" (I have Redme 10C)
It is this switch from point 2 that prevents the application from using GPS when the application is not running
and more. So that the timeout does not fall (sometimes this happens) I made a wrapper with my artificial timeout
My bad, I did forgot to ask for background geolocation permission. You're correction is working great once this one is collected 😅 But thank you for your response and time (it still might help someone else 😃)
Shipped in version 3.1.0
Good afternoon! In the simple mode of the application, everything works well.
Permissions have already been requested and received.
Now I want the Headless (https://reactnative.dev/docs/headless-js-android) script to work with coordinates, but I always get null
Here are excerpts from the code:
index.js
BackgroundHeadlessJSTask.js
After analyzing the situation, I began to receive an error:
mReactContext.getCurrentActivity() returned null but should be non-null in getCurrentLocationData
Error in file: node_modules@react-native-community\geolocation\android\src\main\java\com\reactnativecommunity\geolocation\PlayServicesLocationManager.java
I do not know what to do...