Hi,
Great library, we have successfully implemented this on iOS but on Android we are experiencing force closes. The error seems to come from com.marianhello.bgloc.Config.writeToParcel
desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
stationaryRadius: 50,
distanceFilter: 50,
notificationTitle: 'Background tracking',
notificationText: 'enabled',
debug: true,
startOnBoot: false,
stopOnTerminate: false,
locationProvider: BackgroundGeolocation.ACTIVITY_PROVIDER,
interval: 10000,
fastestInterval: 5000,
activitiesInterval: 10000,
stopOnStillActivity: false,
url: 'our url',
httpHeaders: {
'X-FOO': 'bar'
},
// customize post properties
postTemplate: {
lat: '@latitude',
lon: '@longitude',
}
When we include your library in our android project, the app force closes and becomes unusable.
The app should load, wait for the user activity, authorise location permissions through OS prompt, begin tracking.
It force closes on launch.
Preventing core functionality in our app. Trying to track users in background.
What is the version of plugin and config options?
Updated question with config :)
I don't see anything what could cause config to throw IOException writing serializable object (name = com.marianhello.bgloc.data.HashMapLocationTemplate) as I found in your log. Are you sure you don't use some fancy object in postTemplate?
What is the output of BackgroundGeolocation.getConfig(c=>console.log(c)); before you call BackgroundGeolocation.start()
Will check ASAP. The way we implemented the js side was in a helper component in our top level app structure. I don鈥檛 think the js was even being executed before the force close - I suspect the issue is on the initialisation of the native module. I鈥檒l try and do some more digging for tomorrow. It鈥檚 for an important project though so we have managed to mitigate this using a background task runner to call the navigator getcurrentposition method at an interval. We would love to be able to implement your solution though!
If I鈥檓 able to I will be happy to propose a fix by way of PR.
Ok I can reproduce your issue with:
postTemplate: {
lat: '@latitude',
lon: '@longitude',
crash: {
a: 'a',
b: 'b'
}
}
As stated in documentation object values are not supported only strings. However this should not crash app, so will take look onto it.
Fixed in alpha.25. Now plugin throws js error when non string keys detected
EDIT: so configuration errors can be trapped early in development process (famous react-native red error screen).
Awesome, thank you, will pick this up again today and see if we can get it working our end. Thanks for the speedy fix!
You're welcome. Keep in mind that this fix, that will probably throw error in your case. :) But from react's red error screen you should be able to determine what config props is wrong.
That's fine, thanks, looks like we will configure a new endpoint on our API to accept the flattened object - or is there a way to specify a function that handles the API calls ourselves?
Well you can also rewrite plugin to be able to read object values. Such a contribution will be welcome.
Will have a look into this when I get some free time :)
@antwan2093 latest alpha.26 kind of support nested objects and arrays, ~but first level only~:
Eg. this will work:
BackgroundGeolocation.configure({
postTemplate: {
arr: ['123', 'abc'],
complex: {
foo: 'bar'
}
}
});
~However second level another Object will be serialized as [Object].~
EDIT: It should be working to any level. I did stupid in mistake on server side printing with console.log only, instead of JSON.stringify!