Open pdeep29 opened 8 months ago
On Android 13 and 14 works well. Since Android 14 you have to add new permission and define service into Manifest.xml file for foreground service type. Code example below. Add permission:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" android:minSdkVersion="34" />
and service:
<service android:name="com.backgroundrunner.BackgroundRunnerTask" android:exported="true" android:foregroundServiceType="location"/>
since i have been facing this issue in react-native background actions i have found a solution with this changes
react-native-background-actions package android folder androidmanifest.xml
replace -
react-native background actions RNBackgroundActionsTask.java file changes
replace -
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
with - 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);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
project android manifext.xml all following changes
<intent-filter android:label="filter_react_native">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="MarketingApp" />
</intent-filter>
</activity>
<!-- <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" /> -->
<service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" android:foregroundServiceType="dataSync" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
since i found the solutions given above closing the issue
When i start Service.startRunnerTask it works fine in android 12 or bellow but in android 13 and above app gets crashed in android device.