Cordova-plugin-background-geolocation: iOS crashes on BackgroundGeolocation.start()

Created on 22 Oct 2019  路  7Comments  路  Source: mauron85/cordova-plugin-background-geolocation

When trying to start the geolocation, the app crashes without any message, error handling or anything else.

Your Environmentnumeric version changes over the time -->

  • Plugin version: 3.0.3 (newest)
  • Platform: iOS
  • OS version: 12
  • Device manufacturer and model: iPhone 6, iOS 12
  • Running in Simulator: Not possible
  • Cordova version (cordova -v): newest (already reinstalled)
  • Cordova platform version (cordova platform ls): newest (already reinstalled)
  • Plugin configuration options:
  • Link to your project:

Context

Im just calling the start method with all granted permissions.
When starting the app, it crashes instantly after calling BackgroundGeolocation.start();
I麓ve tried everything but ios debugging with javascript, cordova and ionic is like hell.
Thus im trying to fix that issue with your help, to see if there are any methods to avoid this crash.
The ionicerrorhandler isn麓t even called, because that should normally send a report to sentry (what it doesn麓t do)

Things i麓ve tried:

  • Running on different devies (ios 12, 13)
  • granting permissions manually
  • remove and add plattform
  • remove and add plugin

P.S. on android everything works fine.

The code im using:

BackgroundGeolocation.configure({
                locationProvider: BackgroundGeolocation.DISTANCE_FILTER_PROVIDER,
                desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
                stationaryRadius: 1,
                distanceFilter: 30,
                interval: 1000,
                fastestInterval: 1000,
                activitiesInterval: 1000,
                saveBatteryOnBackground: true,
                maxLocations: 1,
                activityType: "AutomotiveNavigation",
                debug: false,
            });
            this.startGettingLocations(); // registers an "on('location')" listener

            await this.log("Configure Done"); // pops up
            BackgroundGeolocation.start(); // Crashes
            await this.log("Background location started.");

Expected Behavior

The Geolocator should start...

Actual Behavior

Crash

Possible Fix

/

Steps to Reproduce

  1. Call BackgroundGeolocation.start();

Context

Already tried many different things, and after a week trying to debug with mac os (virtually, dedicated, physically, virtualbox) im trying this way

Debug logs

No logs.

If you need any more information: im going to provide it asap.

Most helpful comment

As already mentioned above, setting the information via config.xml worked.
If somebody is facing the same issue, the first approach should be debugging the app with XCode directly.

But i set the config things like shown below

<config-file parent="NSBluetoothAlwaysUsageDescription" platform="ios" target="*-Info.plist"> <string>Yeet your information to ios, even if its not shown ANYWHERE f*kin apple</string> </config-file> <config-file parent="NSLocationAlwaysUsageDescription" platform="ios" target="*-Info.plist"> <string>Yeet your information to ios, even if its not shown ANYWHERE f*kin apple</string> </config-file> <config-file parent="NSLocationWhenInUseUsageDescription" platform="ios" target="*-Info.plist"> <string>Yeet your information to ios, even if its not shown ANYWHERE f*kin apple</string> </config-file> <config-file parent="NSMotionUsageDescription" platform="ios" target="*-Info.plist"> <string>Yeet your information to ios, even if its not shown ANYWHERE f*kin apple</string> </config-file>

All 7 comments

I'm running into this situation as well. Android works fine, but iOS crashes. Are you getting any messages within XCode when the app fails?

Mine is retuning the following:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull intValue]: unrecognized selector sent to instance 0x1db647e28'

hi there,
i managed to fix the issue above by setting alle correct Information in the plist file.
I debugged it with xcode, that worked very well.

Im not using thhe config settings of the plugin and wrote it in the config xml by myself

So i think your issue isnt related to this issue

Would you provide us with your solution please instead of just simply closing this thread without helping others?

As already mentioned above, setting the information via config.xml worked.
If somebody is facing the same issue, the first approach should be debugging the app with XCode directly.

But i set the config things like shown below

<config-file parent="NSBluetoothAlwaysUsageDescription" platform="ios" target="*-Info.plist"> <string>Yeet your information to ios, even if its not shown ANYWHERE f*kin apple</string> </config-file> <config-file parent="NSLocationAlwaysUsageDescription" platform="ios" target="*-Info.plist"> <string>Yeet your information to ios, even if its not shown ANYWHERE f*kin apple</string> </config-file> <config-file parent="NSLocationWhenInUseUsageDescription" platform="ios" target="*-Info.plist"> <string>Yeet your information to ios, even if its not shown ANYWHERE f*kin apple</string> </config-file> <config-file parent="NSMotionUsageDescription" platform="ios" target="*-Info.plist"> <string>Yeet your information to ios, even if its not shown ANYWHERE f*kin apple</string> </config-file>

I'm still getting this error with this config:

  • config.xml
<config-file parent="NSLocationAlwaysUsageDescription" platform="ios" target="*-Info.plist">
    <string>La app requiere saber tu ubicaci贸n todo el tiempo</string>
</config-file>
<config-file parent="NSLocationWhenInUseUsageDescription" platform="ios" target="*-Info.plist">
    <string>La app requiere saber tu ubicaci贸n solo cuando est谩 activa</string>
</config-file>
<config-file parent="NSMotionUsageDescription" platform="ios" target="*-Info.plist">
    <string>La app require saber los datos de movimiento del dispositivo</string>
</config-file>
<config-file parent="NSLocationAlwaysAndWhenInUseUsageDescription" platform="ios" target="*-Info.plist">
    <string>La app requiere saber siempre tu ubicaci贸n solo cuando est谩 activa</string>
</config-file>
  • Background geolocation config:
const backgroundGeolocationConfig: BackgroundGeolocationConfig = {
  desiredAccuracy: 10,
  stationaryRadius: 20,
  distanceFilter: 10,
  debug: false, //  enable this hear sounds for background-geolocation life-cycle.
  stopOnTerminate: false, // enable this to clear background location settings when the app terminates
  notificationTitle: 'Background tracking',
  notificationText: 'enabled',
  url: '/location',
  httpHeaders: {
    'token': null
  },
  // Android only section
  locationProvider: 1,
  startForeground: true,
  interval: 10000,
  fastestInterval: 20000,
  activitiesInterval: 10000,
  startOnBoot: true, // Start background service on device boot
  // iOS only section
  pauseLocationUpdates: false, // Pauses location updates when app is paused,
  saveBatteryOnBackground: false
}

backgroundGeolocation
    .configure(backgroundGeolocationConfig)
    .then(() => backgroundGeolocation.start())

Any help is really appreciated! <3

Nervermind, the url was wrong, it would be much better to avoid crashing the app if that HTTP request fail :)

Was this page helpful?
0 / 5 - 0 ratings