Skip to content

Commit aeb2f90

Browse files
fcaldarellignprice
authored andcommitted
Fix joltup#303 - Error: java.lang.SecurityException when registering a receiver - Android 14
This is cherry-picked from a commit found in react-native-blob-util, a fork of rn-fetch-blob: RonRadtke@2554c32c1 (cherry picked from commit 2554c32)
1 parent 3ea8218 commit aeb2f90

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ public void run() {
196196
DownloadManager dm = (DownloadManager) appCtx.getSystemService(Context.DOWNLOAD_SERVICE);
197197
downloadManagerId = dm.enqueue(req);
198198
androidDownloadManagerTaskTable.put(taskId, Long.valueOf(downloadManagerId));
199-
appCtx.registerReceiver(this, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
199+
if(Build.VERSION.SDK_INT >= 34 ){
200+
appCtx.registerReceiver(this, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), Context.RECEIVER_EXPORTED);
201+
}else{
202+
appCtx.registerReceiver(this, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
203+
}
200204
return;
201205
}
202206

0 commit comments

Comments
 (0)