@kesha-antonov/react-native-background-downloader 3.2.1 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,5 +25,5 @@ dependencies {
25
25
  //noinspection GradleDynamicVersion
26
26
  implementation 'com.facebook.react:react-native:+'
27
27
  implementation 'com.tencent:mmkv:1.3.4'
28
- implementation 'com.google.code.gson:gson:2.10.1'
28
+ implementation 'com.google.code.gson:gson:2.11.0'
29
29
  }
@@ -189,10 +189,18 @@ public class RNBackgroundDownloaderModule extends ReactContextBaseJavaModule {
189
189
  }
190
190
  };
191
191
 
192
- if (Build.VERSION.SDK_INT >= 34) {
193
- context.registerReceiver(downloadReceiver, filter, Context.RECEIVER_EXPORTED);
192
+ compatRegisterReceiver(context, downloadReceiver, filter, true);
193
+ }
194
+
195
+ // TAKEN FROM
196
+ // https://github.com/facebook/react-native/pull/38256/files#diff-d5e21477eeadeb0c536d5870f487a8528f9a16ae928c397fec7b255805cc8ad3
197
+ private void compatRegisterReceiver(Context context, BroadcastReceiver receiver, IntentFilter filter,
198
+ boolean exported) {
199
+ if (Build.VERSION.SDK_INT >= 34 && context.getApplicationInfo().targetSdkVersion >= 34) {
200
+ context.registerReceiver(
201
+ receiver, filter, exported ? Context.RECEIVER_EXPORTED : Context.RECEIVER_NOT_EXPORTED);
194
202
  } else {
195
- context.registerReceiver(downloadReceiver, filter);
203
+ context.registerReceiver(receiver, filter);
196
204
  }
197
205
  }
198
206
 
@@ -485,11 +493,18 @@ public class RNBackgroundDownloaderModule extends ReactContextBaseJavaModule {
485
493
 
486
494
  private void loadDownloadIdToConfigMap() {
487
495
  synchronized (sharedLock) {
488
- String str = mmkv.decodeString(getName() + "_downloadIdToConfig");
489
- if (str != null) {
490
- Gson gson = new Gson();
491
- TypeToken<Map<Long, RNBGDTaskConfig>> mapType = new TypeToken<Map<Long, RNBGDTaskConfig>>() {};
492
- downloadIdToConfig = gson.fromJson(str, mapType);
496
+ try {
497
+ String str = mmkv.decodeString(getName() + "_downloadIdToConfig");
498
+ if (str != null) {
499
+ Gson gson = new Gson();
500
+
501
+ TypeToken<Map<Long, RNBGDTaskConfig>> mapType = new TypeToken<Map<Long, RNBGDTaskConfig>>() {
502
+ };
503
+
504
+ downloadIdToConfig = (Map<Long, RNBGDTaskConfig>) gson.fromJson(str, mapType);
505
+ }
506
+ } catch (Exception e) {
507
+ Log.e(getName(), "loadDownloadIdToConfigMap: " + Log.getStackTraceString(e));
493
508
  }
494
509
  }
495
510
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kesha-antonov/react-native-background-downloader",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "A library for React-Native to help you download large files on iOS and Android both in the foreground and most importantly in the background.",
5
5
  "keywords": [
6
6
  "react-native",