Answer the question
In order to leave comments, you need to log in
How to call native sharing with a file on Safari for iOS?
A web page for mobile, an image is generated in canvas that can be downloaded and saved to the device.
There is also an experimental technology Navigator.share() , and with it it turns out to open a native sharing dialog.
cnv.toBlob((blob) => {
const file = new File([blob], filename, {type: blob.type}); // PNG by default
share(file);
})
const share = (file) => {
const filesArray = [file];
if (navigator.canShare && navigator.canShare({ files: filesArray })) {
navigator.share({
files: filesArray,
title: 'Hello',
text: 'World',
})
.then(() => errorLog('Share was successful.'))
.catch((error) => errorLog('Sharing failed: ' + error));
} else {
errorLog(`Your system doesn't support sharing files.`);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question