BackgroundGeolocation.on('location', location => {
LoggerService.info('Location is changed', null, 'location');
BackgroundGeolocation.startTask(async taskKey => {
console.log(location);
window.cordova.plugins.notification.local.schedule({
title: 'Location is changed',
text: '!!!!!!!!',
});
axios
.post(
${Config.SERVER_URL}location
, location)
.then(() => {
LoggerService.success(
'Location is sending to server',
null,
'location',
);
})
.catch(err => {
LoggerService.error(
'Error sending location to server',
err,
'location',
);
});
const deviceAddress = await BluetoothService.getConnectedDeviceAddress();
console.log(deviceAddress);
if (deviceAddress) {
await BluetoothService.sendLocationToDevice(location, deviceAddress);
LoggerService.success(
'Location is send to device',
deviceAddress,
'location',
);
}
BackgroundGeolocation.endTask(taskKey);
});
});