For the complete documentation index, see llms.txt. This page is also available as Markdown.

File Download JavaScript API

Download files securely using the WebToNative JavaScript API. Enable seamless file downloads and storage within your Android and iOS app.

You need to append "wtn-download-file=true" in query parameter.

<a href="download-url?wtn-download-file=true"> download File</a>
or 
window.location.href = "download-url?wtn-download-file=true";

For Android you don't need to do any extra handling. it will work for App if it works for Browser.

In iOS For blob files download

You need to append "filename=your-file-name.extension" in query parameter.

For example 
For video - blob:https://video_url?filename="abc.mp4"
For image - blob:https://image_url?filename="myImage.png"
For pdf - blob:https://pdf_url?filename="document.pdf"

Blob feature added on 03/11/2023

Additonal Support for iOS Blob Download

Alternate method

You'll need to import the javascript file in your website.

<script src="https://unpkg.com/webtonative@1.0.89/webtonative.min.js"></script>

window.WTN.downloadBlobFile({
    fileName:"your_file_name.pdf",
    downloadUrl:link_to_the_file,    
    shareFileAfterDownload: true,
    openFileAfterDownload: false
})

Pass the filename and blob file url for example - blob:https://pdf_url
shareFileAfterDownload - Opens the share option
openFileAfterDownload - opens the file in a window inside app

Function added on 06/08/2024
Function updated on 02/02/2026

Additional Support for Android File Download

fileName - The desired file name for download

downloadUrl - Link to the file download location

mimeType (optional) - The download file mimeType to support opening the file in respective application and have proper extension while download

cookies (optional) - To pass any user cookies for downloading

isBlob (optional) - Boolean value, to specify if download method uses blob fle download

userAgent (optional) - To customise the userAgent while downloading

openFileAfterDownload (optional) - Boolean Value, to open the file after it has been successfully downloaded, it is compulsory to pass fileName and mimeType for this to work when setting it true.

Last updated