transistorsoft / cordova-background-geolocation-firebase

Firebase Adapter for Cordova Background Geolocation
MIT License
7 stars 5 forks source link

[iOS] not configuring locationsCollection/geofencesCollection will result in a crash #11

Closed tafh closed 5 years ago

tafh commented 5 years ago

Your Environment

Actual Behavior

On iOS not configuring either the locationsCollection or geofencesCollection can result in a crash when it tries to write the log to the not configured collection.

Expected Behavior

This should not crash the app. And remind the developer to configure the collectionName.

Steps to Reproduce

Don't configure the geofencesCollection like so: bgGeoFirebase.configure({ locationsCollection: 'geopositions', });

Now trigger a geofence. This will crash the app.

Solution

You should check if the collectionName is not nil in the onPersist method (and give the developer a hint to configure the collection). So it will not try to write the a 'nil' path.

ps on Android I did not encounter this problem.

christocracy commented 5 years ago

Where the crash log?

tafh commented 5 years ago

Here you go:

✅-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+XX.XXXXXX,+X.XXXXXXX> +/- 65.00m (speed -1.00 mps / course -1.00) @ 11/09/2019, 13:42:30 British Summer Time 2019-09-11 13:42:30.441333+0100 MyApp[5352:2010775] ✅-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+XX.XXXXXX,+X.XXXXXXX> +/- 65.00m (speed -1.00 mps / course -1.00) @ 11/09/2019, 13:42:30 British Summer Time ℹ️-[TSConfig persist] 2019-09-11 13:42:30.443148+0100 MyApp[5352:2010782] ℹ️-[TSConfig persist] 2019-09-11 13:42:30.444093+0100 MyApp[5352:2010807] Terminating app due to uncaught exception 'FIRInvalidArgumentException', reason: 'Collection path cannot be nil.' First throw call stack: (0x18fd35c20 0x18fa500c8 0x100ad01f8 0x1008a2a04 0x1008d1dc0 0x1005a4f38 0x103099e48 0x10309b2a8 0x1030acccc 0x1030ad418 0x18fa42a60 0x18fa48c78) libc++abi.dylib: terminating with uncaught exception of type NSException

christocracy commented 5 years ago

Try installing from branch ios-default-collections

ionic cordova plugin add https://github.com/transistorsoft/cordova-background-geolocation-firebase.git#ios-default-collections
tafh commented 5 years ago

What exactly is different in this branch? (I was not able to spot any differences)

christocracy commented 5 years ago

Forgot the commit. Try again.

christocracy commented 5 years ago

Let me know if that branch fixes your issue so I can release it to npm.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

stale[bot] commented 5 years ago

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.