react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Tracking not working in IOS when app is terminated

Open GurjeetLamba opened this issue 2 years ago • 10 comments

I am getting issue in getting location update in IOS , when app is terminated . I have checked all the setup process for IOS . Don't know what I am missing here I just don't get the notifications which I get in sample app of background geolocation during the tracking , Does I need to define the Permitted background task scheduler identifiers as below in my info Plist

Your Environment

  • Plugin version:"^4.12.1"

  • react-native-background-fetch: "^4.0.1",

  • Platform: iOS

  • OS version : 16.5.1

  • Device manufacturer / model: apple/ i-phone 12

  • React Native version (react-native -v): 0.64

  • Plugin config const state = await BackgroundGeolocation.ready({ url: API_URL + API_ENDPOINTS.SAVELOCATION,

    logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
    desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
    distanceFilter: 10,
    
    stopTimeout: 5,
    locationTemplate:
      '{"Latitude":<%= latitude %>,"Longitude":<%= longitude %>,"TimeStamp": "<%= timestamp %>"}',
    locationAuthorizationRequest: 'Always',
    backgroundPermissionRationale: {
      title:
        "Allow {applicationName} to access this device's location even when closed or not in use.",
      message:
        'This app collects location data to enable recording your trips to work and calculate distance-travelled.',
      positiveAction: 'Change to "{backgroundPermissionOptionLabel}"',
      negativeAction: 'Cancel',
    },
    headers: {
      authorization: 'Bearer ' + getToken.data.Token,
      source: source,
    },
    params: {
      ClientId: respo_storage.data.ClientId,
    },
    batchSync: true,
    autoSync: true,
    maxDaysToPersist: 14,
    stopOnTerminate: false,
    startOnBoot: true,
    enableHeadless: true,
    preventSuspend:true
    

    });

Screenshot 2023-07-26 at 3 17 34 PM

Expected Behavior

App should track location even when in background or terminated

Actual Behavior

After terminating app location is not tracking

GurjeetLamba avatar Jul 26 '23 09:07 GurjeetLamba

See wiki Debugging. Learn to fetch logs.

I test iOS daily for the last 8 years. It’s rock solid and never fails.

christocracy avatar Jul 26 '23 10:07 christocracy

17b707cb-548e-4462-902d-684e7c8c02e8.gz

I have fetch the log but don't understand anything from it after opening the .gz file after 14:15 today App was terminated but no location update is noticed after that, Please help me understand what the log is saying, Pls confirm about info Plist, In my project I have to use same identifier ?

GurjeetLamba avatar Jul 26 '23 10:07 GurjeetLamba

Your device acquired a stationary geofence with a very poor accuracy of 4631.11m (4.6km).

Why is your device location-accuracy so poor? Have you turned off Wifi?

You will likely have to move at least 4.6km before iOS fires geofence around your last known location, causing the plugin to enter the moving state.

2023-07-26 13:39:20.251 ✅-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+30.72759788,+76.70188259> +/- 4631.11m (speed 0.00 mps / course 0.00) @ 26/07/23, 1:39:20 PM India Standard Time


2023-07-26 14:22:43.801 
📍<+30.72696648,+76.69739149> +/- 4631.11m (speed 0.00 mps / course 0.00) @ 26/07/23, 2:22:43 PM India Standard Time

christocracy avatar Jul 26 '23 13:07 christocracy

device was connected through wifi during this time. But the device was not having any sim , we have connected it through hotspot wifi of other device

GurjeetLamba avatar Jul 26 '23 13:07 GurjeetLamba

According to this my device may have moved a less distance and it have not entered in the moving state due to which location have not updated

GurjeetLamba avatar Jul 26 '23 13:07 GurjeetLamba

iPhones don't require a SIM for location-services to work. Figure out why your device is returning poor accuracy locations.

christocracy avatar Jul 26 '23 13:07 christocracy

And Wifi doesn't need to be connected to a network for location-services to return a location from Wifi.

christocracy avatar Jul 26 '23 13:07 christocracy

But in my case the location didn't even updated when app terminated not even with poor accuracy

GurjeetLamba avatar Jul 26 '23 13:07 GurjeetLamba

You will likely have to move at least 4.6km before iOS fires geofence around your last known location, causing the plugin to enter the moving state.

christocracy avatar Jul 26 '23 13:07 christocracy

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar May 07 '24 01:05 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar May 22 '24 01:05 github-actions[bot]