PDF download file not working
Back to All

PDF download file not working

Hello, it seems that file download is not working on our app but works in most common browsers.

Right now, there are instances the pdf shows only but no options and another one is that it doesn't work already.

Here's the code:

function downloadPdf(link) {
  // ref: https://median.co/docs/custom-user-agent
  if (
    navigator.userAgent.indexOf("gonative") > -1 ||
    navigator.userAgent.indexOf("median") > -1
  ) {
    // ref: https://median.co/docs/download-file
    const downloadFile = median?.share?.downloadFile || gonative?.share?.downloadFile;

    if (downloadFile) {
        downloadFile({ url: link });
        return;
    }
  }

  window.location.href = link;
}