Closed GaelCO closed 9 months ago
While waiting for compatibility, I reset my targetSDKVersion to 33.
I think issue come from the notification Intent. to resolve it.
To resolve issue :
replace line 44
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_MUTABLE); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); } else { contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); }
by
if (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) { contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_MUTABLE); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); } else { contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); }
And change compileSdkVersion to 34 to have UPSIDE_DOWN_CAKE in version code
Indeed, you must also add the type of service. I have modified the previous lines in my node-module. fix the first issue, but an other occurs:
Unable to start service com.asterinet.react.bgactions.RNBackgroundActionsTask@797185c with Intent { cmp=com.package/com.asterinet.react.bgactions.RNBackgroundActionsTask (has extras) }: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{6cccc30 12448:com.package/u0a191} targetSDK=34
Hi,
This library is not compatible with API level 34. If targetSdkVersion is set to 34, the app crash.
Since API Level 34, for security reason, creating or retrieving a PendingIntent with FLAG_MUTABLE, an implicit Intent within and without FLAG_NO_CREATE and FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT was disallowed.
Crashlytics log :
Fatal Exception: java.lang.RuntimeException: Unable to start service com.asterinet.react.bgactions.RNBackgroundActionsTask@6de2756 with Intent { cmp=com.package/com.asterinet.react.bgactions.RNBackgroundActionsTask (has extras) }: java.lang.IllegalArgumentException: com.package: Targeting U+ (version 34 and above) disallows creating or retrieving a PendingIntent with FLAG_MUTABLE, an implicit Intent within and without FLAG_NO_CREATE and FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT for security reasons. To retrieve an already existing PendingIntent, use FLAG_NO_CREATE, however, to create a new PendingIntent with an implicit Intent use FLAG_IMMUTABLE. at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4839) at android.app.ActivityThread.-$$Nest$mhandleServiceArgs() at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2289) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8177) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
I'm not sure, but I think the foreground service need to precise the type too. https://developer.android.com/about/versions/14/changes/fgs-types-required?hl=fr