Skip to content

Commit

Permalink
feat: pass notification title to android module
Browse files Browse the repository at this point in the history
  • Loading branch information
LMakshow committed Dec 19, 2024
1 parent e066569 commit 9f3f1ba
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion android/src/main/java/com/eko/RNBGDTaskConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ public class RNBGDTaskConfig implements Serializable {
public String url;
public String destination;
public String metadata = "{}";
public String notificationTitle;
public boolean reportedBegin;

public RNBGDTaskConfig(String id, String url, String destination, String metadata) {
public RNBGDTaskConfig(String id, String url, String destination, String metadata, String notificationTitle) {
this.id = id;
this.url = url;
this.destination = destination;
this.metadata = metadata;
this.notificationTitle = notificationTitle;
this.reportedBegin = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ public void download(ReadableMap options) {
String destination = options.getString("destination");
ReadableMap headers = options.getMap("headers");
String metadata = options.getString("metadata");
String notificationTitle = options.getString("notificationTitle");
int progressIntervalScope = options.getInt("progressInterval");
if (progressIntervalScope > 0) {
progressInterval = progressIntervalScope;
Expand All @@ -281,6 +282,10 @@ public void download(ReadableMap options) {
request.setRequiresCharging(false);
}

if (notificationTitle != null) {
request.setTitle(notificationTitle);
}

if (headers != null) {
ReadableMapKeySetIterator iterator = headers.keySetIterator();
while (iterator.hasNextKey()) {
Expand All @@ -295,7 +300,7 @@ public void download(ReadableMap options) {
request.setDestinationInExternalFilesDir(this.getReactApplicationContext(), null, filename);

long downloadId = downloader.download(request);
RNBGDTaskConfig config = new RNBGDTaskConfig(id, url, destination, metadata);
RNBGDTaskConfig config = new RNBGDTaskConfig(id, url, destination, metadata, notificationTitle);

synchronized (sharedLock) {
configIdToDownloadId.put(id, downloadId);
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export interface DownloadOption {
isAllowedOverRoaming?: boolean;
isAllowedOverMetered?: boolean;
isNotificationVisible?: boolean;
notificationTitle?: string;
}

export type Download = (options: DownloadOption) => DownloadTask;
Expand Down
2 changes: 2 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ type DownloadOptions = {
isAllowedOverRoaming?: boolean,
isAllowedOverMetered?: boolean,
isNotificationVisible?: boolean;
notificationTitle?: string,
}

export function download (options: DownloadOptions) {
Expand All @@ -148,6 +149,7 @@ export function download (options: DownloadOptions) {

RNBackgroundDownloader.download({
...options,
notificationTitle: options.notificationTitle,
metadata: JSON.stringify(options.metadata),
progressInterval: config.progressInterval,
})
Expand Down

0 comments on commit 9f3f1ba

Please sign in to comment.