React-native-background-geolocation: Upgrade from react-native-background-geolocation (3.2.0 -> 3.4.2) & react-native-background-fetch (2.7.0 -> 2.8.0)

Created on 12 Feb 2020  路  8Comments  路  Source: transistorsoft/react-native-background-geolocation

Your Environment

  • Plugin version: 3.4.2
  • Platform: iOS
  • OS version: 13.3.1
  • Device manufacturer / model: Apple
  • React Native version (react-native -v): 0.60.6
  • Plugin config
    ```javascript
    const MANUALCONFIGIOS = {
    // Geolocation Config
    desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
    distanceFilter: 10,
    stopOnTerminate: true,
    startOnBoot: false,
    stopTimeout: 5,
    stopDetectionDelay: 5,
    logLevel: BackgroundGeolocation.LOG_LEVEL_OFF
    };
## Expected Behavior
<!--- Tell us what should happen -->
On previous version (3.2.0 user was able to start, stop, then start background geolocation without fatal crash. 
## Actual Behavior
<!--- Tell us what happens instead -->
When a user stops background geolocation tasks (linked to an onPress event), then starts again (the initial run works fine). The app has a fatal crash and displays the following in xCode debug. This does not happen in rnbg 3.2.0 with rnbf 2.7.0).

2020-02-12 12:59:01.493 [info][tid:com.facebook.react.JavaScript] GPS: Configuring and Starting Services
2020-02-12 12:59:01.493322+0000 Awesome[2062:136252] GPS: Configuring and Starting Services
2020-02-12 12:59:01.493 [info][tid:com.facebook.react.JavaScript] No configuration supplied - assuming manual mode, determining platform OS
2020-02-12 12:59:01.493433+0000 Awesome[2062:136252] No configuration supplied - assuming manual mode, determining platform OS
2020-02-12 12:59:01.493 [info][tid:com.facebook.react.JavaScript] IOS detected
2020-02-12 12:59:01.493491+0000 Awesome[2062:136252] IOS detected
2020-02-12 12:59:01.494 [info][tid:com.facebook.react.JavaScript] { desiredAccuracy: -1,
distanceFilter: 10,
stopOnTerminate: true,
startOnBoot: false,
stopTimeout: 5,
stopDetectionDelay: 5,
logLevel: 0 }
2020-02-12 12:59:01.494329+0000 Awesome[2062:136252] { desiredAccuracy: -1,
distanceFilter: 10,
stopOnTerminate: true,
startOnBoot: false,
stopTimeout: 5,
stopDetectionDelay: 5,
logLevel: 0 }
2020-02-12 12:59:01.505254+0000 Awesome[2062:136252] Accelerometer
2020-02-12 12:59:01.505494+0000 Awesome[2062:141355] setUpdateInterval: 100.000000
2020-02-12 12:59:01.508657+0000 Awesome[2062:141355] startUpdates
REMOVED ACCELERATOR DEBUGGING LINES FOR CLARITY OF THIS ISSUE
2020-02-12 12:59:06.494454+0000 Awesome[2062:135983] startAccelerometerUpdates: -0.080017, -0.611786, -0.816498, 14721.090623
2020-02-12 12:59:06.522 [info][tid:com.facebook.react.JavaScript] Stopping Background Geolocation Services
2020-02-12 12:59:06.522452+0000 Awesome[2062:136252] Stopping Background Geolocation Services
2020-02-12 12:59:06.533429+0000 Awesome[2062:141355] stopUpdates
2020-02-12 12:59:09.996 [info][tid:com.facebook.react.JavaScript] GPS: Configuring and Starting Services
2020-02-12 12:59:09.996638+0000 Awesome[2062:136252] GPS: Configuring and Starting Services
2020-02-12 12:59:09.997 [info][tid:com.facebook.react.JavaScript] No configuration supplied - assuming manual mode, determining platform OS
2020-02-12 12:59:09.996911+0000 Awesome[2062:136252] No configuration supplied - assuming manual mode, determining platform OS
2020-02-12 12:59:09.997 [info][tid:com.facebook.react.JavaScript] IOS detected
2020-02-12 12:59:09.997078+0000 Awesome[2062:136252] IOS detected
2020-02-12 12:59:10.000 [info][tid:com.facebook.react.JavaScript] { desiredAccuracy: [Getter/Setter],
distanceFilter: [Getter/Setter],
stopOnTerminate: [Getter/Setter],
startOnBoot: [Getter/Setter],
stopTimeout: [Getter/Setter],
stopDetectionDelay: [Getter/Setter],
logLevel: [Getter/Setter] }
2020-02-12 12:59:10.000137+0000 Awesome[2062:136252] { desiredAccuracy: [Getter/Setter],
distanceFilter: [Getter/Setter],
stopOnTerminate: [Getter/Setter],
startOnBoot: [Getter/Setter],
stopTimeout: [Getter/Setter],
stopDetectionDelay: [Getter/Setter],
logLevel: [Getter/Setter] }
2020-02-12 12:59:10.014097+0000 Awesome[2062:140647] setUpdateInterval: 100.000000
2020-02-12 12:59:10.018253+0000 Awesome[2062:141472] startUpdates
2020-02-12 12:59:10.037122+0000 Awesome[2062:135983] -[TSBackgroundFetch start]: unrecognized selector sent to instance 0x2830caa00
2020-02-12 12:59:10.043848+0000 Awesome[2062:135983]
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TSBackgroundFetch start]: unrecognized selector sent to instance 0x2830caa00'*
* First throw call stack:
(0x1bebcc96c 0x1be8e5028 0x1beacadcc 0x1bebd1048 0x1bebd33a0 0x102df6144 0x104c7de1c 0x104c7f27c 0x104c8d32c 0x1beb47cc8 0x1beb42a24 0x1beb41f40 0x1c8dd2534 0x1c2ccd580 0x102203148 0x1be9c0e18)
libc++abi.dylib: terminating with uncaught exception of type NSException

## Steps to Reproduce
<!--- reproduce this issue; include code to reproduce, if relevant -->
1. Start geolocation services by calling function:

this.configureAndStartBackgroundLocation = config => {
console.log(GPS: Configuring and Starting Services);
if (!config) {
console.log(
"No configuration supplied - assuming manual mode, determining platform OS"
);
if (Platform.OS === "ios") {
config = MANUALCONFIGIOS;
console.log("IOS detected");
console.log(config);
} else {
config = MANUALCONFIGANDROID;
console.log("Android detected");
console.log(config);
}
}
BackgroundGeolocation.ready(config, state => {
// console.log(
// "- BackgroundGeolocation is configured and ready: ",
// state.enabled
// );

    if (!state.enabled) {
      ////
      // 3. Start tracking!
      //
      BackgroundGeolocation.start(function() {
        //console.log("- Start success");
      });
    }
  });
};
2. Stop geolocation services by calling function:
`this.stopBackgroundLocation = () => {
      console.log("Stopping Background Geolocation Services");
      BackgroundGeolocation.stop();
    };`
3.Start again and error occurs. This is not present in 3.2.0.

## Context
<!--- What were you trying to do? -->
Testing the start and stop of background GPS services as per our unit testing.
## Debug logs
Included in the description above

``` <!-- Syntax highlighting:  DO NOT REMOVE -->
2020-02-12 12:59:01.493 [info][tid:com.facebook.react.JavaScript] GPS: Configuring and Starting Services
2020-02-12 12:59:01.493322+0000 Awesome[2062:136252] GPS: Configuring and Starting Services
2020-02-12 12:59:01.493 [info][tid:com.facebook.react.JavaScript] No configuration supplied - assuming manual mode, determining platform OS
2020-02-12 12:59:01.493433+0000 Awesome[2062:136252] No configuration supplied - assuming manual mode, determining platform OS
2020-02-12 12:59:01.493 [info][tid:com.facebook.react.JavaScript] IOS detected
2020-02-12 12:59:01.493491+0000 Awesome[2062:136252] IOS detected
2020-02-12 12:59:01.494 [info][tid:com.facebook.react.JavaScript] { desiredAccuracy: -1,
  distanceFilter: 10,
  stopOnTerminate: true,
  startOnBoot: false,
  stopTimeout: 5,
  stopDetectionDelay: 5,
  logLevel: 0 }
2020-02-12 12:59:01.494329+0000 Awesome[2062:136252] { desiredAccuracy: -1,
  distanceFilter: 10,
  stopOnTerminate: true,
  startOnBoot: false,
  stopTimeout: 5,
  stopDetectionDelay: 5,
  logLevel: 0 }
2020-02-12 12:59:01.505254+0000 Awesome[2062:136252] Accelerometer
2020-02-12 12:59:01.505494+0000 Awesome[2062:141355] setUpdateInterval: 100.000000
2020-02-12 12:59:01.508657+0000 Awesome[2062:141355] startUpdates
REMOVED ACCELERATOR DEBUGGING LINES FOR CLARITY OF THIS ISSUE
2020-02-12 12:59:06.494454+0000 Awesome[2062:135983] startAccelerometerUpdates: -0.080017, -0.611786, -0.816498, 14721.090623
2020-02-12 12:59:06.522 [info][tid:com.facebook.react.JavaScript] Stopping Background Geolocation Services
2020-02-12 12:59:06.522452+0000 Awesome[2062:136252] Stopping Background Geolocation Services
2020-02-12 12:59:06.533429+0000 Awesome[2062:141355] stopUpdates
2020-02-12 12:59:09.996 [info][tid:com.facebook.react.JavaScript] GPS: Configuring and Starting Services
2020-02-12 12:59:09.996638+0000 Awesome[2062:136252] GPS: Configuring and Starting Services
2020-02-12 12:59:09.997 [info][tid:com.facebook.react.JavaScript] No configuration supplied - assuming manual mode, determining platform OS
2020-02-12 12:59:09.996911+0000 Awesome[2062:136252] No configuration supplied - assuming manual mode, determining platform OS
2020-02-12 12:59:09.997 [info][tid:com.facebook.react.JavaScript] IOS detected
2020-02-12 12:59:09.997078+0000 Awesome[2062:136252] IOS detected
2020-02-12 12:59:10.000 [info][tid:com.facebook.react.JavaScript] { desiredAccuracy: [Getter/Setter],
  distanceFilter: [Getter/Setter],
  stopOnTerminate: [Getter/Setter],
  startOnBoot: [Getter/Setter],
  stopTimeout: [Getter/Setter],
  stopDetectionDelay: [Getter/Setter],
  logLevel: [Getter/Setter] }
2020-02-12 12:59:10.000137+0000 Awesome[2062:136252] { desiredAccuracy: [Getter/Setter],
  distanceFilter: [Getter/Setter],
  stopOnTerminate: [Getter/Setter],
  startOnBoot: [Getter/Setter],
  stopTimeout: [Getter/Setter],
  stopDetectionDelay: [Getter/Setter],
  logLevel: [Getter/Setter] }
2020-02-12 12:59:10.014097+0000 Awesome[2062:140647] setUpdateInterval: 100.000000
2020-02-12 12:59:10.018253+0000 Awesome[2062:141472] startUpdates
**2020-02-12 12:59:10.037122+0000 Awesome[2062:135983] -[TSBackgroundFetch start]: unrecognized selector sent to instance 0x2830caa00
2020-02-12 12:59:10.043848+0000 Awesome[2062:135983] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TSBackgroundFetch start]: unrecognized selector sent to instance 0x2830caa00'**
*** First throw call stack:
(0x1bebcc96c 0x1be8e5028 0x1beacadcc 0x1bebd1048 0x1bebd33a0 0x102df6144 0x104c7de1c 0x104c7f27c 0x104c8d32c 0x1beb47cc8 0x1beb42a24 0x1beb41f40 0x1c8dd2534 0x1c2ccd580 0x102203148 0x1be9c0e18)
libc++abi.dylib: terminating with uncaught exception of type NSException

Most helpful comment

$ yarn add [email protected]

All 8 comments

Setup instructions need to be updated since I release [email protected].

Background-geolocation isn鈥檛 ready for it.

Pin [email protected]

$ yarn add [email protected]

Thanks, @christocracy - I can confirm that using 2.7.1 has fixed the problem. Closing this issue.

In iOS, react-native-background-fetch 3.0.3 is failing with react-native-background-geolocation 3.4.2

[email protected] resolves issue.

That鈥檚 correct. The install docs explicitly specify to install 2.7.1.

The next release of [email protected] is compatible with latest [email protected]

We are also experiencing this on cordova. Is there a specific version of cordova-plugin-background-fetch to install? if so, what is the CLI to add? Thanks!

If you have an issue with Cordova, this closed RN issue is not the place to seek support. Post an issue there.

Nvm, I think it is 5.6.1. I just un-installed both fetch and geolocation, and when I added plugin for latest and greatest, it automatically installed version 5.6.1 . I think one of my developers installed fetch first, and then I forced geolocation to use that upated version. Hope that helps someone!

Was this page helpful?
0 / 5 - 0 ratings