Manage native background file downloads, PDF saving, progress notifications, and opening files in external apps.
Manage native background file downloads and PDF exports. Nativine embeds native iOS URLSessionDownloadTask and Android DownloadManager bridges, replacing webview download failures with native background downloading, progress notification bars, and instant previewing.
Downloading PDFs, invoices, zip archives, or media files inside webviews often fails or displays raw binary code. Nativine's Download Manager plugin intercepts file download requests at the OS layer:
To trigger a background file download from JavaScript, call nativine.downloadManager.downloadFile():
nativine.downloadManager.downloadFile({
url: 'https://yourdomain.com/invoices/inv_9988.pdf',
filename: 'Invoice_9988.pdf',
mimeType: 'application/pdf',
showNotification: true,
openOnComplete: true,
callback: 'onDownloadCompleted',
onProgress: 'onDownloadProgress'
});
function onDownloadProgress(progress) {
console.log("Download Progress:", progress.percent + "%");
}
| Parameter | Type | Description |
|---|---|---|
url | string | Required. File download URL string. |
filename | string | Required. Desired target filename saved on device storage. |
openOnComplete | boolean | Optional. Set true to open native file preview immediately when finished. |
Files are saved directly to the device Downloads/ directory and registered in the Android MediaStore.
Yes. The native download task automatically forwards session cookies and authorization headers from the active web view.