-
Notifications
You must be signed in to change notification settings - Fork 427
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
iOS Device Tracking Not Working After App is Terminated #2233
Comments
There's no such thing as "headless iOS". The API docs explicitly note that headless-mode is an Android-only mechanism. To learn more about the behaviour of iOS after terminate, see API doc Also see this video The only way to re-awaken a terminated iOS app is to move at least 200 meters. |
Thank you for the clarification! I understand now that: Headless tasks are Android-only. Thanks again for the guidance! |
Why? What do you hope that’s going to do? |
I aim to track user movements after the app is terminated and log location updates when significant changes (200+ meters) occur. I thought useSignificantChangesOnly would help achieve this. If there's a better approach, please advise. |
I am not able to trigger my background task after the app has been terminated. The JavaScript code stops executing once the app is terminated, and I cannot seem to execute the task after the app wakes up from termination. Could you guide me on how to properly configure the library to execute a background task after wake from termination? I've ensured that the necessary background modes are configured in Info.plist (both location and fetch). |
Have you read the API docs for The easiest way to test iOS is in the Simulator with location simulated with Freeway Drive, as demonstrated in the video I linked above.
After app terminate, go outside and move at least 200 meters with the plugin configured with |
In iOS, the device location service does not start after the app is terminated.
Plugin version: "react-native-background-geolocation": "^4.18.2",
Platform: IOS
OS version: 16.7.10
Device manufacturer / model: Iphone 8
React Native version (
react-native -v
): 0.69.4Plugin config : -
BackgroundGeolocation.ready({
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
distanceFilter: 0, // meters
enableHeadless: true,
stopOnTerminate: false, // Continue tracking in the background
startOnBoot: true, // Start automatically after device reboot
debug: true, // Shows debug sounds and notifications (useful during development)
locationUpdateInterval: 10000, // 30 seconds interval
fastestLocationUpdateInterval: 10000, // Minimum interval is 15 seconds (for faster passive updates)
// stationaryRadius: 50,
useSignificantChangesOnly: false, // Enable SLC
preventSuspend: true, // Prevent app from suspending when stationary
heartbeatInterval: 20, // Heartbeat every 30 seconds (or your preferred interval)
desiredOdometerAccuracy: 50, // Only use locations with accuracy < 30 meters for odometer updates
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
locationAuthorizationRequest: 'Always', // iOS permission
}, (state) => {
console.log("BackgroundGeolocation is ready: ", state.enabled);
});
Expected Behavior
I want to get the location when the app is in the terminated state. Can we use HeadlessTask for iOS?
Actual Behavior
Location is not being retrieved after the app is terminated.
Steps to Reproduce
register in index.js
BackgroundGeolocation.registerHeadlessTask(BackgroundTask);
const BackgroundTask = async (event) => {
console.log('[BackgroundGeolocation HeadlessTask] - Event:', event.name, event.params);
const currentTime = Date.now();
}
The text was updated successfully, but these errors were encountered: