react-native-background-actions
react-native-background-actions copied to clipboard
App Crashes with ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask
"react-native": "0.73.0", "react-native-background-actions": "^4.0.1",
My App crashes as soon as it tries to start the foreground task with runtime exception.I have included android:foregroundServiceType to be dataSync and connectedDevice as the app uses ble and also needs to upload information.
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
Above are the permissions included in the AndroidManifest.xml file and App uses
PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN,
PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT,
PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION
are the runtime permission.
Error which i get is E AndroidRuntime: java.lang.RuntimeException: Unable to start service com.asterinet.react.bgactions.RNBackgroundActionsTask@dee0a74 with Intent { cmp=com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask (has extras) }: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask.
Crashed only on Android 14.
Checked the example in the library. App crashes and says the app has a bug.
@Rapsssito Please let me know if i am missing anything. Thankyou in Advance.
@muramidaza any solution? I facing the same issue.
Hello,
Thankyou for responding.
"react-native": "0.73.0", "react-native-background-actions": "^4.0.1",
My App crashes as soon as it tries to start the foreground task with runtime exception.I have included android:foregroundServiceType to be dataSync and connectedDevice as the app uses ble and also needs to upload information.
Above are the permissions included in the AndroidManifest.xml file and App uses
PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN, PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT, PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS, PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION
are the runtime permission.
Error which i get is E AndroidRuntime: java.lang.RuntimeException: Unable to start service @.*** with Intent { cmp=com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask (has extras) }: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask.
Crashed only on Android 14.
Checked the example in the library. App crashes and says the app has a bug.
On Tue, Dec 3, 2024 at 10:19 AM Iván González @.***> wrote:
@smitha-2020 https://github.com/smitha-2020 which version are you using?
— Reply to this email directly, view it on GitHub https://github.com/Rapsssito/react-native-background-actions/issues/251#issuecomment-2513834524, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARIKKRU3EVX7435XSWHHPOL2DVSSJAVCNFSM6AAAAABS25YVGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJTHAZTINJSGQ . You are receiving this because you were mentioned.Message ID: @.*** com>
Hello, Thankyou for responding. "react-native": "0.73.0", "react-native-background-actions": "^4.0.1", My App crashes as soon as it tries to start the foreground task with runtime exception.I have included android:foregroundServiceType to be dataSync and connectedDevice as the app uses ble and also needs to upload information.
Above are the permissions included in the AndroidManifest.xml file and App uses PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN, PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT, PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS, PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION are the runtime permission. Error which i get is E AndroidRuntime: java.lang.RuntimeException: Unable to start service @.*** with Intent { cmp=com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask (has extras) }: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask. Crashed only on Android 14. Checked the example in the library. App crashes and says the app has a bug. … On Tue, Dec 3, 2024 at 10:19 AM Iván González @.> wrote: @smitha-2020 https://github.com/smitha-2020 which version are you using? — Reply to this email directly, view it on GitHub <#251 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARIKKRU3EVX7435XSWHHPOL2DVSSJAVCNFSM6AAAAABS25YVGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJTHAZTINJSGQ . You are receiving this because you were mentioned.Message ID: @. com>
Try with this
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected] for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/RNBackgroundActionsTask.java b/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/RNBackgroundActionsTask.java
index 9900fc0..2fc7ceb 100644
--- a/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/RNBackgroundActionsTask.java
+++ b/node_modules/react-native-background-actions/android/src/main/java/com/asterinet/react/bgactions/RNBackgroundActionsTask.java
@@ -42,9 +42,9 @@ final public class RNBackgroundActionsTask extends HeadlessJsTaskService {
}
final PendingIntent contentIntent;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
- contentIntent = PendingIntent.getActivity(context,0, notificationIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT);
+ contentIntent = PendingIntent.getActivity(context,0, notificationIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
- contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_MUTABLE);
+ contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
} else {
This issue body was partially generated by patch-package.
Hello Iván,
I tried changing the lines in the RNBackgroundActionTask
But the error still exists and the app crashes whenever it tries to start the background.
Thankyou.
On Tue, Dec 3, 2024 at 11:24 AM smitha kamath @.***> wrote:
Hello,
Thankyou for responding.
"react-native": "0.73.0", "react-native-background-actions": "^4.0.1",
My App crashes as soon as it tries to start the foreground task with runtime exception.I have included android:foregroundServiceType to be dataSync and connectedDevice as the app uses ble and also needs to upload information.
Above are the permissions included in the AndroidManifest.xml file and App uses
PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN, PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT, PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS, PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION
are the runtime permission.
Error which i get is E AndroidRuntime: java.lang.RuntimeException: Unable to start service @.*** with Intent { cmp=com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask (has extras) }: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask.
Crashed only on Android 14.
Checked the example in the library. App crashes and says the app has a bug.
On Tue, Dec 3, 2024 at 10:19 AM Iván González @.***> wrote:
@smitha-2020 https://github.com/smitha-2020 which version are you using?
— Reply to this email directly, view it on GitHub https://github.com/Rapsssito/react-native-background-actions/issues/251#issuecomment-2513834524, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARIKKRU3EVX7435XSWHHPOL2DVSSJAVCNFSM6AAAAABS25YVGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJTHAZTINJSGQ . You are receiving this because you were mentioned.Message ID: @.*** com>
Hello Iván, I tried changing the lines in the RNBackgroundActionTask But the error still exists and the app crashes whenever it tries to start the background. Thankyou. On Tue, Dec 3, 2024 at 11:24 AM smitha kamath @.> wrote: … Hello, Thankyou for responding. "react-native": "0.73.0", "react-native-background-actions": "^4.0.1", My App crashes as soon as it tries to start the foreground task with runtime exception.I have included android:foregroundServiceType to be dataSync and connectedDevice as the app uses ble and also needs to upload information.
Above are the permissions included in the AndroidManifest.xml file and App uses PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN, PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT, PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS, PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION are the runtime permission. Error which i get is E AndroidRuntime: java.lang.RuntimeException: Unable to start service @. with Intent { cmp=com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask (has extras) }: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask. Crashed only on Android 14. Checked the example in the library. App crashes and says the app has a bug. On Tue, Dec 3, 2024 at 10:19 AM Iván González @.> wrote: > @smitha-2020 https://github.com/smitha-2020 which version are you > using? > > — > Reply to this email directly, view it on GitHub > <#251 (comment)>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/ARIKKRU3EVX7435XSWHHPOL2DVSSJAVCNFSM6AAAAABS25YVGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJTHAZTINJSGQ > . > You are receiving this because you were mentioned.Message ID: > @. > com> >
Could you please share the error that you get but from Android Studio?
Hello,
I am using the Android 14 device connected to the usb. I cannot use the simulator as iam working with ble.
12-03 12:10:43.625 19432 19432 E AndroidRuntime: FATAL EXCEPTION: main 12-03 12:10:43.625 19432 19432 E AndroidRuntime: Process: com.sim.simsim, PID: 19432 12-03 12:10:43.625 19432 19432 E AndroidRuntime: java.lang.RuntimeException: Unable to start service @.*** with Intent { cmp=com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask (has extras) }: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5286) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2531) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:230) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.os.Looper.loop(Looper.java:319) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8919) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: Caused by: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.os.Parcel.readParcelableInternal(Parcel.java:4882) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.os.Parcel.readParcelable(Parcel.java:4864) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.os.Parcel.createExceptionOrNull(Parcel.java:3064) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.os.Parcel.createException(Parcel.java:3053) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:3036) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2978) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7234) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.app.Service.startForeground(Service.java:775) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at com.asterinet.react.bgactions.RNBackgroundActionsTask.onStartCommand(RNBackgroundActionsTask.java:93) 12-03 12:10:43.625 19432 19432 E AndroidRuntime: at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5268)
On Tue, Dec 3, 2024 at 12:06 PM Iván González @.***> wrote:
Hello Iván, I tried changing the lines in the RNBackgroundActionTask But the error still exists and the app crashes whenever it tries to start the background. Thankyou. On Tue, Dec 3, 2024 at 11:24 AM smitha kamath @.
> wrote: … <#m_7878177758717104091_> Hello, Thankyou for responding. "react-native": "0.73.0", "react-native-background-actions": "^4.0.1", My App crashes as soon as it tries to start the foreground task with runtime exception.I have included android:foregroundServiceType to be dataSync and connectedDevice as the app uses ble and also needs to upload information. Above are the permissions included in the AndroidManifest.xml file and App uses PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN, PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT, PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS, PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION are the runtime permission. Error which i get is E AndroidRuntime: java.lang.RuntimeException: Unable to start service @. with Intent { cmp=com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask (has extras) }: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.sim.simsim/com.asterinet.react.bgactions.RNBackgroundActionsTask. Crashed only on Android 14. Checked the example in the library. App crashes and says the app has a bug. On Tue, Dec 3, 2024 at 10:19 AM Iván González @.*> wrote: > @smitha-2020 https://github.com/smitha-2020 https://github.com/smitha-2020 https://github.com/smitha-2020 which version are you > using? > > — > Reply to this email directly, view it on GitHub > <#251 (comment) https://github.com/Rapsssito/react-native-background-actions/issues/251#issuecomment-2513834524>,
or unsubscribe > https://github.com/notifications/unsubscribe-auth/ARIKKRU3EVX7435XSWHHPOL2DVSSJAVCNFSM6AAAAABS25YVGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJTHAZTINJSGQ https://github.com/notifications/unsubscribe-auth/ARIKKRU3EVX7435XSWHHPOL2DVSSJAVCNFSM6AAAAABS25YVGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJTHAZTINJSGQ . > You are receiving this because you were mentioned.Message ID: > @.* com> >
Could you please share the error that you get but from Android Studio?
— Reply to this email directly, view it on GitHub https://github.com/Rapsssito/react-native-background-actions/issues/251#issuecomment-2514097819, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARIKKRS6WA2QEK4N323NQKD2DV7CPAVCNFSM6AAAAABS25YVGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJUGA4TOOBRHE . You are receiving this because you were mentioned.Message ID: @.*** com>
Did you request notification permission this way? It is required on Android 13+
await PermissionsAndroid.request("android.permission.POST_NOTIFICATIONS");
I have added it this way
const requestBLEPermission = async () => { if (Platform.OS !== 'android') { return; } if (Platform.Version >= 31) { PermissionsAndroid.requestMultiple([ PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN, PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT, PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS, ]).then((result) => { if (result) { console.debug( '[handleAndroidPermissions] User accepts runtime permissions android 12+', ); } else { console.error( '[handleAndroidPermissions] User refuses runtime permissions android 12+', ); } }); } };
On Tue, Dec 3, 2024 at 1:10 PM smitha kamath @.***> wrote:
ok let me remove it
On Tue, Dec 3, 2024 at 12:51 PM Iván González @.***> wrote:
Did you request notification permission this way? It is required on Android 13+
await PermissionsAndroid.request("android.permission.POST_NOTIFICATIONS");
— Reply to this email directly, view it on GitHub https://github.com/Rapsssito/react-native-background-actions/issues/251#issuecomment-2514204688, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARIKKRSJGLL54XZCZH52B332DWEMZAVCNFSM6AAAAABS25YVGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJUGIYDINRYHA . You are receiving this because you were mentioned.Message ID: @.*** com>
Is there any settings or configuration taht needs to be added as specified by this https://reactnative.dev/docs/headless-js-android
On Tue, Dec 3, 2024 at 1:19 PM smitha kamath @.***> wrote:
I have added it this way
const requestBLEPermission = async () => { if (Platform.OS !== 'android') { return; } if (Platform.Version >= 31) { PermissionsAndroid.requestMultiple([ PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN, PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT, PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS, ]).then((result) => { if (result) { console.debug( '[handleAndroidPermissions] User accepts runtime permissions android 12+', ); } else { console.error( '[handleAndroidPermissions] User refuses runtime permissions android 12+', ); } }); } };
On Tue, Dec 3, 2024 at 1:10 PM smitha kamath @.***> wrote:
ok let me remove it
On Tue, Dec 3, 2024 at 12:51 PM Iván González @.***> wrote:
Did you request notification permission this way? It is required on Android 13+
await PermissionsAndroid.request("android.permission.POST_NOTIFICATIONS");
— Reply to this email directly, view it on GitHub https://github.com/Rapsssito/react-native-background-actions/issues/251#issuecomment-2514204688, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARIKKRSJGLL54XZCZH52B332DWEMZAVCNFSM6AAAAABS25YVGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJUGIYDINRYHA . You are receiving this because you were mentioned.Message ID: @.*** com>
I used version 3.0.1 and had to patch it (because of android compileSdkVersion). These are my changes. I hope you find them useful.
<service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" android:foregroundServiceType="connectedDevice|dataSync|location"/>
Do we need anather library react-native-foreground-service?
const uploadFromBackground = async () => {
let playing = BackgroundJob.isRunning();
playing = !playing;
if (playing) {
try {
await BackgroundJob.start(veryIntensiveTask, options);
await BackgroundService.updateNotification({
taskDesc: ` ${new Date()}`,
});
console.log('Successful start!');
} catch (e) {
console.log('Error', e);
}
}
};
const veryIntensiveTask = async (taskData: any) => {
// Example of an infinite loop task
const {delay} = taskData;
await new Promise(async (resolve) => {
//upload data
for (let i = 0; BackgroundService.isRunning(); i++) {
//uploading here
await BackgroundService.updateNotification({
taskDesc: ` Last Updated at: ${new Date()}`,
});
console.log('sleeping...');
await sleep(delay);
}
});
};
compileSdkVersion = 34 targetSdkVersion = 34
@BagasNS could you look into this issue please.
Had the same issue and fixed by adding these lines from here: https://github.com/Rapsssito/react-native-background-actions/pull/236/files
Thankyou @rokanost. Tried it. Its still gives the same problem. Crashes as soon as the background task starts.
I'm also facing this issue on the release Store, on both android 13 and android 14
@patphantuan251 Did you happen to solve it ?
@patphantuan251Bạn có giải quyết được vấn đề đó không?
I tried cleaning all cache, then following @rokanost and it worked on my device. However, after pushing to the store, the problem still occurs every day with a few users (about 10 people) and I still haven't been able to fix it.
@patphantuan251 what is the version of react native and react-native-background-actions you are using? and also what are the foregroundServiceTypes you are targetting?
@patphantuan251Bạn có giải quyết được vấn đề đó không?
I tried cleaning all cache, then following @rokanost and it worked on my device. However, after pushing to the store, the problem still occurs every day with a few users (about 10 people) and I still haven't been able to fix it.
Same with me.. works on dev mode, but crashing in Prod. Looks like the release build permission is:
<service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask"/>
and it should be:
<service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" android:foregroundServiceType="dataSync"/>
SOLUTION: Found a fork that fixed the issue (my app now works fine in production) https://www.npmjs.com/package/react-native-bg-actions
Hello @rokanost @ivangonzalezg @patphantuan251 @smitha-2020,
I’m encountering an issue with my production app. While I’ve managed to fix the crash issue, I’m still facing a problem with the microphone functionality.
Could anyone assist in resolving this? I’d really appreciate any guidance or support in fixing this behavior.
For more context, here's the related issue: https://github.com/Rapsssito/react-native-background-actions/issues/254#issue-2812232276
Environment: "react-native": "^0.73.8" "react-native-background-actions": "^4.0.1"
Path - node_modules\react-native-background-actions\android\src\main\AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.asterinet.react.bgactions"> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" /> <application> <service android:name=".RNBackgroundActionsTask" android:foregroundServiceType="dataSync"/> </application> </manifest>
Thanks in advance!
Hello @rokanost @ivangonzalezg @patphantuan251 @smitha-2020,
I’m encountering an issue with my production app. While I’ve managed to fix the crash issue, I’m still facing a problem with the microphone functionality.
Could anyone assist in resolving this? I’d really appreciate any guidance or support in fixing this behavior.
For more context, here's the related issue: #254 (comment)
Environment: "react-native": "^0.73.8" "react-native-background-actions": "^4.0.1"
Path - node_modules\react-native-background-actions\android\src\main\AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.asterinet.react.bgactions"> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" /> <application> <service android:name=".RNBackgroundActionsTask" android:foregroundServiceType="dataSync"/> </application> </manifest>Thanks in advance!
@rokanost can you please help on this issue https://github.com/Rapsssito/react-native-background-actions/issues/254#issue-2812232276
Same with me.. works on dev mode, but crashing in Prod. Looks like the release build permission is:
<service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask"/>and it should be:
<service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" android:foregroundServiceType="dataSync"/>SOLUTION: Found a fork that fixed the issue (my app now works fine in production) https://www.npmjs.com/package/react-native-bg-actions
Yep, this is the same for me. Works in development (emulator and physical device w/ adb) but the preview/production APK crashes. When I inspect the manifest file within the APK, I also see that the android:foregroundServiceType="dataSync" property.
FOREGROUND_SERVICE_LOCATION & DATA_SYNC: Required and correctly added for Android 14+ — ensures your foreground service is not silently blocked.
foregroundServiceType="location|dataSync": ✅ Correct — you're telling the system what types of foreground tasks this service will handle.
<service
android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask"
android:foregroundServiceType="location|dataSync"
android:exported="false"
/>
Means the service will stop when your app's task is removed (like swiping it away from recent apps).
This is okay if you're not trying to run location updates after the user kills the app manually.
❌ If your goal is to keep tracking even when the app is killed, this should be false and you need a strategy like WorkManager or BroadcastReceiver for BOOT and KILL handling.