My case is when user click on a button. A CSV file will be downloaded to their device.
const encodedUri = encodeURI(csvContent); const link = document.createElement("a"); link.setAttribute("href", encodedUri); link.setAttribute("download",
${fileName}.csv); link.style.width = "0px"; link.style.height = "0px"; link.style.visibility = "hidden"; link.style.position = "absolute"; link.target = "_blank"; document.body.appendChild(link); link.click(); document.body.removeChild(link);
This is the function to download the CSV file. It only works on browser. But my mobile app (ReactJS Webview) it failed.
The error say : Failed to open URL data:text/csv;charset=utf-8,FirstName,LastName,PhoneNumber,Email%0A,,,: Error Domain=NSOSStatusErrorDomain Code=-10814 “(null)” UserInfo={_LSLine=277, _LSFunction=-[_LSDOpenClient openURL:fileHandle:options:completionHandler:]}
Hopefully someone can tell my how to solve this problem. Thank you guys.