diff --git a/README.md b/README.md index 35420b2..96493bb 100644 --- a/README.md +++ b/README.md @@ -215,6 +215,7 @@ An object containing options properties | `headers` | Object | | All | Costume headers to add to the download request. These are merged with the headers given in the `setConfig({ headers: { ... } })` function | | `isAllowedOverRoaming` | Boolean | | Android | whether this download may proceed over a roaming connection. By default, roaming is allowed | | `isAllowedOverMetered` | Boolean | | Android | Whether this download may proceed over a metered network connection. By default, metered networks are allowed | +| `showNotification` | Boolean | | Android | Whether to show a download notification or not | **returns** diff --git a/android/src/main/java/com/eko/RNBackgroundDownloaderModule.java b/android/src/main/java/com/eko/RNBackgroundDownloaderModule.java index 754f481..539ba4d 100644 --- a/android/src/main/java/com/eko/RNBackgroundDownloaderModule.java +++ b/android/src/main/java/com/eko/RNBackgroundDownloaderModule.java @@ -361,6 +361,7 @@ public class RNBackgroundDownloaderModule extends ReactContextBaseJavaModule { boolean isAllowedOverRoaming = options.getBoolean("isAllowedOverRoaming"); boolean isAllowedOverMetered = options.getBoolean("isAllowedOverMetered"); + boolean showNotification = options.getBoolean("showNotification"); if (id == null || url == null || destination == null) { Log.e(getName(), "id, url and destination must be set"); @@ -371,7 +372,7 @@ public class RNBackgroundDownloaderModule extends ReactContextBaseJavaModule { final Request request = new Request(Uri.parse(url)); request.setAllowedOverRoaming(isAllowedOverRoaming); request.setAllowedOverMetered(isAllowedOverMetered); - request.setNotificationVisibility(Request.VISIBILITY_HIDDEN); + request.setNotificationVisibility(showNotification ? Request.VISIBILITY_VISIBLE : Request.VISIBILITY_HIDDEN); request.setRequiresCharging(false); int uuid = (int) (System.currentTimeMillis() & 0xfffffff); diff --git a/index.d.ts b/index.d.ts index 45475eb..af8bdfd 100644 --- a/index.d.ts +++ b/index.d.ts @@ -106,6 +106,7 @@ export interface DownloadOption { metadata?: object; isAllowedOverRoaming?: boolean; isAllowedOverMetered?: boolean; + showNotification?: boolean; } export type Download = (options: DownloadOption) => DownloadTask; diff --git a/index.ts b/index.ts index b538e59..bdeb31d 100644 --- a/index.ts +++ b/index.ts @@ -121,6 +121,7 @@ type DownloadOptions = { metadata?: object, isAllowedOverRoaming?: boolean, isAllowedOverMetered?: boolean, + showNotification?: boolean; } export function download(options: DownloadOptions) { @@ -137,6 +138,7 @@ export function download(options: DownloadOptions) { if (options.isAllowedOverRoaming == null) options.isAllowedOverRoaming = true if (options.isAllowedOverMetered == null) options.isAllowedOverMetered = true + if (options.showNotification == null) options.showNotification = false const task = new DownloadTask({ id: options.id,