Cordova-plugin-background-geolocation: iOS 13.1 Beta - Geolocation not reported when app is in background

Created on 9 Sep 2019  Â·  17Comments  Â·  Source: mauron85/cordova-plugin-background-geolocation


Seems like the geolocation is not reported when the app runs in background despite the "Always" permission is set

Your Environment


  • Plugin version: 3.0.6
  • Platform: iOS 13.1 beta
  • OS version:
  • Device manufacturer and model: IPhone 6s
  • Cordova version (cordova -v): 9.0.0 (cordova-lib 9.0.1)
  • Cordova platform version (cordova platform ls): ios 5.0.1
  • Plugin configuration options:
  • Link to your project:

Context

On iOS 13.1 when the user has checked in the settings of the app the "always" permission for the iOS, the location is not beeing recorded after one leaves the app (switches the app to background i.e.).

I can see that on the navtive Cordova Background Geolocation It this issue has been already raised and solved:
transistorsoft/cordova-background-geolocation-lt#952

Expected Behavior

The Geolocation should be properly sent even if the app is in the background

Steps to Reproduce

  1. Turn on the "Always" geolocation permission (turned on from the settings page, not from the prompt - as it is no longer available in the iOS 13).
  2. Start tracking the geolocation
  3. Go to the desktop
  4. After approx. 30 seconds the location arrow on the top bar will disappear and the geolocation requests will cease beeing sent to the server.
  5. Going back to the application reenables sending of the geolocation requests

All 17 comments

@mauron85 I am sorry for being pushy, but do you have a clue about this one? iOS 13 releases tomorrow, there might be a great impact if the background geoloc report would not work in the background. For now, the issue still persists.

It seems to be a general issue with iOS 13.

  • You dont get (not every time, but sometimes, cant say explicit when) the blue tracking icon
  • If the new authority confirm box (Only in foreground, Once, Never) you got BackgroundGeolocation.AUTHORIZED, if the user select "only in foreground".
    -- So the trackings stops in background without any response or callback etc. If you resume the app, you got the question from ios if you allowed every time in background and the tracking jumps from the last point in foreground to the current point

But i dont have any idea atm to solve the issue :/

@busaku Mhm, thank you for the reply, well, at least I am not the only one fighting this bug.

Is seems the issue happens only with ACTIVITY_PROVIDER, when using RAW_PROVIDER (and app has proper permissions) geolocation in background works fine.

Hello @tkondej how to change that setting?

@itcurves simply by specifying locationProvider, check the example https://github.com/mauron85/cordova-plugin-background-geolocation#example

@tkondej, I'm still having issues with background data sending to my server using RAW_PROVIDER - I currently use DISTANCE_FILTER_PROVIDER but I switched to RAW_PROVIDER for testing. Both fail. I was wondering if you could explain what you mean by "and app has proper permissions". My app used to work prior to IOS13 so I was wondering if there is a new permission required for IOS13?

@stgraham2000 on iOS 13 you have to enable access to use "geolocation always" in application settings or by accepting additional prompt which popups when after locking and unlocking the phone, check this article for more details https://medium.com/@transistorsoft/ios-13-and-android-q-support-beb7595d2c24

@tkondej, interesting, I had the "always on" under permissions for most of the day and it appeared to be broken, but it looks like another thing to look out for is you need to go for a longer distance test run. In earlier tests today I was probably only walking maybe 50m (around my office). I just tried again by doing a short drive and the points were collected as I expected. Before when I was testing on ios12 I could get points with a much shorter distance travelled. This will be an interesting usability issue to address as the article you referenced also indicates.

It looks like this should still be possible to accomplish location updates while the permissions are set to "while in use":

https://developer.apple.com/documentation/corelocation/getting_the_user_s_location/handling_location_events_in_the_background
https://developer.apple.com/documentation/corelocation/cllocationmanager/1620568-allowsbackgroundlocationupdates

I will experiment with this in the morning and report back

Any news? :)

Unfortunately, I took horrible notes on this investigation but I have fixed the problem and here are the changes I have in the commit that fixed this...

  • Went from version 3.0.0-alpha.50 to 3.1.0
  • Following is a snippet of the config changed:
startForeground: true,  # Unset prior
pauseLocationUpdates: false  # Unset prior
stationaryRadius: 10    # Used to be 50
  • Was using this.backgroundGeolocation.finish() at the end of the location handler. I removed these.

I hope one of the above changes works for you. Sorry I can't be of more help.

Hello, please look at my posts #684

In your config.xml be sure to add the following configuration under the iOs platform xml node:

        <config-file parent="UIBackgroundModes" target="*-Info.plist">
            <array>
                <string>fetch</string>
            </array>
            <array>
                <string>location</string>
            </array>
            <array>
                <string>processing</string>
            </array>
        </config-file>
        <edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">
            <string>need location access to find things nearby</string>
        </edit-config>

that's equivalent to the following setup from Xcode

77958309-26a26980-72d5-11ea-8812-96afeb264aa5

I have finally got this to work on a real device! the key change:
locationProvider: BackgroundGeolocation.RAW_PROVIDER
i,e, do NOT use ACTIVITY_PROVIDER as shown in the geolocation example in the docs as this doe NOT work in the background on IOS devices as explained here
https://github.com/mauron85/cordova-plugin-background-geolocation/blob/HEAD/PROVIDERS.md

I am not sure the settings mentioned above are also required in the config.xml file under the 'ios platform' sectio. I suspect the default already set by the plugin (i.e. 'location') might be sufficient.

@tfelici - Can you please share reference of your plugin if you have forked and made changes? I also facing same issue.

I have not done any fork. I am using the vanilla 3.1.0 version

Kind regards

Tom
On 11/09/2020 12:05, Anuj Singh wrote:
>

@tfelici https://github.com/tfelici - Can you please share reference
of your plugin if you have forked and made changes? I also facing same
issue.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/mauron85/cordova-plugin-background-geolocation/issues/619#issuecomment-691029600,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AB2PYTFAC43VNIMXLF3LQC3SFH76BANCNFSM4IU5AYGQ.

ok - after further tests I can confirm this woks on IOS 13.7 on my daughter's iphone and ipad. Here are the relevant settings in BackgroundGeolocation.configure

BackgroundGeolocation.configure({
    locationProvider: BackgroundGeolocation.RAW_PROVIDER,
    desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
    pauseLocationUpdates: false, // need this for IOS I think (default was false anyhow but maybe not)
    stationaryRadius: 20, 
    distanceFilter: 20, // docs say this is dinamically changed when locationProvider = DISTANCE_FILTER_PROVIDER
});

you do NOT need to add the extra lines in config.xml under the IOS platform section

    <config-file parent="UIBackgroundModes" target="*-Info.plist">
        <array>
            <string>location</string>
        </array>
        <array>
            <string>processing</string>
        </array>
    </config-file>

unless you require to app to refresh other stuff in the background, other than location updates and posting

Was this page helpful?
0 / 5 - 0 ratings