Forum Discussion

tdxkait's avatar
tdxkait
Copper Contributor
Feb 07, 2024

SPFx Web Part - Functionality Not Working In iOS / Android Sharepoint App

Hi, I was wondering if somebody can point me in the right direction here - experienced web dev, but first time developing in SPFx.

 

I'm developing a web part, and it's working fully as expected after deploying as an App to my test Site... with one exception. I have a dynamically generated data that users can download on request as a .csv via a button in the app. Because of the dynamic nature of the data, this can not be stored as a static file anywhere with a direct URL to download.

 

If I use some fairly commonly-used JS code to achieve this as follows: (data, mimeType, and fileName all strings populated with appropriate values)

const blob = new Blob( [ data ], { type: mimeType } );
const url = window.URL.createObjectURL( blob );

const link = document.createElement( 'a' );
document.body.appendChild( link );

link.href = url;
link.download = fileName;
link.click();

window.URL.revokeObjectURL( url );
document.body.removeChild( link );

 

This triggers upon the download button being clicked in my web part and works as expected in all major browsers tested, both desktop and mobile - the .csv file download immediately begins.

 

However when I hit the download button on the web part from within the Sharepoint mobile app, it does not: on iOS it simply does nothing, on Android the entire app crashes & shuts down!

 

The download is <50KB - it's not a large file so I don't expect that's the issue.

 

I'm not sure whether this is a bug, or something the SharePoint mobile app can't handle, but how can I make this functionality work in both the browser and the app?

No RepliesBe the first to reply

Resources