Skip to content

Commit 2554c32

Browse files
committed
Fix #303 - Error: java.lang.SecurityException when registering a receiver - Android 14
1 parent 2531333 commit 2554c32

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,11 @@ public void run() {
292292
DownloadManager dm = (DownloadManager) appCtx.getSystemService(Context.DOWNLOAD_SERVICE);
293293
downloadManagerId = dm.enqueue(req);
294294
androidDownloadManagerTaskTable.put(taskId, Long.valueOf(downloadManagerId));
295-
appCtx.registerReceiver(this, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
295+
if(Build.VERSION.SDK_INT >= 34 ){
296+
appCtx.registerReceiver(this, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), Context.RECEIVER_EXPORTED);
297+
}else{
298+
appCtx.registerReceiver(this, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
299+
}
296300
future = scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
297301
@Override
298302
public void run() {

0 commit comments

Comments
 (0)