You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello Guys, good morning.
Implement Background Actions to perform a task by calling a native module that scans BLE devices, if I use the cell phone frequently the foregroundservice runs perfectly throughout the day. The problem comes when the screen turns off for several hours, I find that the OS kills the service since I don't see it in the silent notifications. Activate without restrictions to save battery in my app, also in the foregroundservice type I configure it as follows:
Option for notification: <service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" android:foregroundServiceType="connectedDevice|dataSync|location">
I also went on to configure the notification and the task performed below:
O
`const options = {
taskName: 'BLEScanner',
taskTitle: 'Escáner BLE Activo',
taskDesc: 'Buscando dispositivos W6...',
taskIcon: {
name: 'ic_launcher',
type: 'mipmap',
},
color: '#FF0000',
parameters: {
delay: 15000,
},
const veryIntensiveTask = async (taskDataArguments) => {
console.log("Iniciando tarea de escaneo en segundo plano");
let lastPanicSendTime: Date = null;
await new Promise(async (resolve) => {
while (BackgroundService.isRunning()) {
try {
await BackgroundService.updateNotification({
taskDesc: "Escaneando dispositivos W6...",
});
if (
lastPanicSendTime == null ||
new Date().getTime() - lastPanicSendTime.getTime() > 60000
) {
const devices = await CustomModule.scanDevices();
//SI ENCONTRO UN PAQUETE
if (devices.length > 0) {
lastPanicSendTime = new Date();
try {
const locationNativo = await CustomModule.getCurrentLocation();
const locationToSv = formatPosition(locationNativo);
positionStore.sendPosition([locationToSv]);
} catch (error) {
console.error("Error al enviar la posición:", error);
await BackgroundService.updateNotification({
taskDesc: `Error al enviar la posición: ${error.message}`,
});
}
} else {
await BackgroundService.updateNotification({
taskDesc: `No se encontraron dispositivos W6`,
});
}
}
await sleep(SCAN_INTERVAL);
} catch (error) {
console.error("Error en el ciclo de escaneo:", error);
await sleep(SCAN_INTERVAL);
}
}
});
};
`
**Is there any specific configuration or anything I can change to make my foregroundservice more reliable and resilient to being killed by the operating system when the screen is off for several hours?
**
THANK YOU SO MUCH !
The text was updated successfully, but these errors were encountered:
I'm also getting same issue
when use android:foregroundServiceType="shortService" then it works only 3 minutes
when use android:foregroundServiceType="dataSync" then max 40 minutes
Is there any way it should work two or more days without crashing.
I'm also getting same issue when use android:foregroundServiceType="shortService" then it works only 3 minutes when use android:foregroundServiceType="dataSync" then max 40 minutes
Is there any way it should work two or more days without crashing.
@Beckmann0o where you able to solve it? Whats the version of react native and react-native-background-actions you are using. I have issue registered with background on android 14 at #251 . it crashes almost immediately when background task starts.
Hello Guys, good morning.
Implement Background Actions to perform a task by calling a native module that scans BLE devices, if I use the cell phone frequently the foregroundservice runs perfectly throughout the day. The problem comes when the screen turns off for several hours, I find that the OS kills the service since I don't see it in the silent notifications. Activate without restrictions to save battery in my app, also in the foregroundservice type I configure it as follows:
Option for notification:
<service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" android:foregroundServiceType="connectedDevice|dataSync|location">
I also went on to configure the notification and the task performed below:
O
`const options = {
taskName: 'BLEScanner',
taskTitle: 'Escáner BLE Activo',
taskDesc: 'Buscando dispositivos W6...',
taskIcon: {
name: 'ic_launcher',
type: 'mipmap',
},
color: '#FF0000',
parameters: {
delay: 15000,
},
};`
Task configuration::
`const sleep = (time) =>
new Promise((resolve) => setTimeout(() => resolve(), time));
const veryIntensiveTask = async (taskDataArguments) => {
console.log("Iniciando tarea de escaneo en segundo plano");
let lastPanicSendTime: Date = null;
};
`
**Is there any specific configuration or anything I can change to make my foregroundservice more reliable and resilient to being killed by the operating system when the screen is off for several hours?
**
THANK YOU SO MUCH !
The text was updated successfully, but these errors were encountered: