iOS app Crashing on posting to server
Plugin: 2.12.0-beta.2 (happend on 2.12.0 also) Platform: iOS OS version: 11 Device: iPhone 6 RN version: .54 Plugin Config:
BackgroundGeolocation.ready({
reset: true,
desiredAccuracy:0,
distanceFilter:5,
disableElasticity:true,
activityRecognition_interval:50,
stopTimeout: 15,
activityType:"AutomotiveNavigation",
debug:false,
logLevel:0,
stopOnTerminate:false,
preventSuspend:true,
heartbeatInterval:60,
startOnBoot:true,
url:"https://tracker.transistorsoft.com/locations/EsdrasEtrenne",
foregroundService:true,
schedule:["1-7 10:30-21:30"]
params:{
device: {
uuid: DeviceInfo.getUniqueID(),
model: DeviceInfo.getModel(),
platform: DeviceInfo.getSystemName(),
manufacturer: DeviceInfo.getManufacturer(),
version: DeviceInfo.getSystemVersion(),
framework: 'ReactNative'
}
},
}, (state, err) => {
if (!state.enabled) {
BackgroundGeolocation.startSchedule(() => {
console.info('- Scheduler started');
});
}
});
The app crashes, Im not sure when because it is not my device. But it is being reported in the crash reports:
Crashed: com.transistorsoft.TSLocationManager
0 CoreFoundation 0x1870a8640 __CFGetConverter + 18
1 CoreFoundation 0x186fc4684 CFStringEncodingUnicodeToBytes + 148
2 CoreFoundation 0x1870ab074 __CFStringEncodeByteStream + 1716
3 Foundation 0x1879ced2c -[NSString(NSStringOtherEncodings) getBytes:maxLength:usedLength:encoding:options:range:remainingRange:] + 248
4 CoreFoundation 0x1870c98a4 -[NSTaggedPointerString getBytes:maxLength:usedLength:encoding:options:range:remainingRange:] + 124
5 CoreFoundation 0x186fb0ce8 CFStringGetBytes + 144
6 Foundation 0x187b5b00c _convertJSONString + 408
7 Foundation 0x187b5a260 _writeJSONString + 92
8 Foundation 0x187b5b34c ___writeJSONObject_block_invoke + 80
9 CoreFoundation 0x186ffcedc -[__NSDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:] + 160
10 Foundation 0x187b5a984 _writeJSONObject + 388
11 Foundation 0x187b5b3bc ___writeJSONObject_block_invoke + 192
12 CoreFoundation 0x186ffcedc -[__NSDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:] + 160
13 Foundation 0x187b5a984 _writeJSONObject + 388
14 Foundation 0x187b5b3bc ___writeJSONObject_block_invoke + 192
15 CoreFoundation 0x186fa8520 -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 232
16 Foundation 0x187b5a984 _writeJSONObject + 388
17 Foundation 0x187b58df4 -[_NSJSONWriter dataWithRootObject:options:error:] + 140
18 Foundation 0x187b59e44 +[NSJSONSerialization dataWithJSONObject:options:error:] + 348
19 EPDriver 0x102c5aec8 -[TSHttpService doPost:] (TSHttpService.m:279)
20 EPDriver 0x102c5a5d0 -[TSHttpService post:error:] (TSHttpService.m:213)
21 EPDriver 0x102c5a30c -[TSHttpService schedulePost:] (TSHttpService.m:184)
22 EPDriver 0x102c5a6d4 -[TSHttpService post:error:] (TSHttpService.m:219)
23 EPDriver 0x102c5a30c -[TSHttpService schedulePost:] (TSHttpService.m:184)
24 libdispatch.dylib 0x186a5d088 _dispatch_call_block_and_release + 302384
25 libdispatch.dylib 0x186a5d048 _dispatch_client_callout + 301416
26 libdispatch.dylib 0x186a66e48 _dispatch_queue_serial_drain$VARIANT$mp + 302384
27 libdispatch.dylib 0x186a677d8 _dispatch_queue_invoke$VARIANT$mp + 301416
28 libdispatch.dylib 0x186a68200 _dispatch_root_queue_drain_deferred_wlh$VARIANT$mp + 302384
29 libdispatch.dylib 0x186a704a0 _dispatch_workloop_worker_thread$VARIANT$mp + 301416
30 libsystem_pthread.dylib 0x186d02fd0 _pthread_wqthread + 302384
31 libsystem_pthread.dylib 0x186d02c20 start_wqthread + 301416
I think it is the TSHttpService when the app is attempting to do a post request?
Where did you get the idea to provide underscored_config_params??
All the plugin's config params are camelCased.
Review your params and ensure you're not providing any null values:
params:{
device: {
uuid: DeviceInfo.getUniqueID(),
model: DeviceInfo.getModel(),
platform: DeviceInfo.getSystemName(),
manufacturer: DeviceInfo.getManufacturer(),
version: DeviceInfo.getSystemVersion(),
framework: 'ReactNative'
}
},
Also, the #ready method callback does not provide an err argument. Are you reading the docs? You can't just invent your own API.
}, (state, err) => {
``
ah, the configs are camelized. That is just how we are getting it from the server and it is converted on the client. I forgot to change it after copy pasting for the example above.
The code looks like this
let configs = await getDriverConfigs();
BackgroundGeolocation.ready({
reset: true,
...configs,
params:{
device: {
uuid: DeviceInfo.getUniqueID(),
model: DeviceInfo.getModel(),
platform: DeviceInfo.getSystemName(),
manufacturer: DeviceInfo.getManufacturer(),
version: DeviceInfo.getSystemVersion(),
framework: 'ReactNative'
}
}
}, (state, err) => {
if (!state.enabled) {
BackgroundGeolocation.startSchedule(() => {
console.info('- Scheduler started');
});
}
});
For the err I just removed that as well. It was left over after upgrading from the configure function. But the error occurred yesterday as well.
I just checked and the Data for the device is coming back correctly. I just logged the configs to be sure as well and those are coming back correctly camel cased. I will update the original question to camel to clear the confusion
Edit I think it may be that I changed the url to https? For some reason we were not seeing iOS data post until we changed it to https, but that also might have caused the issue as well.
What's the status on this? Btw, customers should post issues to private repo.
Got it. Will do. I think it is fixed. I noticed we had duplicate keys in our configs object. And after a day of testing no crash report