Open thongbbc opened 2 years ago
We are in the process of updating android to 31 and we ran into this also. Reading the readme for the android-upload-service library I noticed a warning that says that in 31 you can't start uploads while your app is in the background. Do you have any experience dealing with this b/c it seems like its breaks the Android side of this library.
Android 5.0 (API 21) to Android 12 (API 31) support. Beware you cannot start uploads while your app is the background on Android 12 due to recent Service limitations
It doesn't seem like android-upload-service has not plans to make background uploads work for 31 and up either statement from the author 1 statement from the author 2
Hello, we have been having this issue on Android app Target 31. Ref document: https://stackoverflow.com/questions/67045607/how-to-resolve-missing-pendingintent-mutability-flag-lint-warning-in-android-a
I tried with solution add dependency into build.gradle
implementation 'androidx.work:work-runtime:2.7.1'
But it still does not work.
-> My latest solution to fix this which is using patch package to modify Native code
class NotificationActions { var INTENT_ACTION = "com.vydia.RNUploader.notification.action" class NotificationActions { val intent = Intent(INTENT_ACTION) intent.putExtra(PARAM_ACTION, ACTION_CANCEL_UPLOAD) intent.putExtra(PARAM_UPLOAD_ID, uploadID) eturn PendingIntent.getBroadcast(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT) val flag = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE else PendingIntent.FLAG_UPDATE_CURRENT return PendingIntent.getBroadcast(context, requestCode, intent, flag) } }
Change
return PendingIntent.getBroadcast(context, requestCode, intent, flag)
toval flag = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE else PendingIntent.FLAG_UPDATE_CURRENT return PendingIntent.getBroadcast(context, requestCode, intent, flag)
I think we should create PR for this. Thanks.
My NotificationActions class is different than yours here is the content of my file
`package com.vydia.RNUploader
import android.app.PendingIntent import android.content.Context import android.content.Intent
class NotificationActions { var INTENT_ACTION = "com.vydia.RNUploader.notification.action"
val PARAM_ACTION = "action" val PARAM_UPLOAD_ID = "uploadId"
val ACTION_CANCEL_UPLOAD = "cancelUpload"
fun getCancelUploadAction(context: Context?, requestCode: Int, uploadID: String?): PendingIntent? { val intent = Intent(INTENT_ACTION) intent.putExtra(PARAM_ACTION, ACTION_CANCEL_UPLOAD) intent.putExtra(PARAM_UPLOAD_ID, uploadID) return PendingIntent.getBroadcast(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT) } }`
How should I edit the return line, I tried your solution but its throwing some errors. My react-native-background-upload version is ^6.6.0
Hello, we have been having this issue on Android app Target 31. Ref document: https://stackoverflow.com/questions/67045607/how-to-resolve-missing-pendingintent-mutability-flag-lint-warning-in-android-a
I tried with solution add dependency into build.gradle
implementation 'androidx.work:work-runtime:2.7.1'
But it still does not work.
-> My latest solution to fix this which is using patch package to modify Native code
Change
return PendingIntent.getBroadcast(context, requestCode, intent, flag)
toI think we should create PR for this. Thanks.