Skip to content

Instantly share code, notes, and snippets.

@happymishra
Last active June 29, 2019 08:33
Show Gist options
  • Select an option

  • Save happymishra/6c06f86d064ca3286467a00bbb61d6fa to your computer and use it in GitHub Desktop.

Select an option

Save happymishra/6c06f86d064ca3286467a00bbb61d6fa to your computer and use it in GitHub Desktop.
var shareData = { files: filesArray };
if (navigator.canShare && navigator.canShare(shareData)) {
// Adding title afterwards as navigator.canShare just
// takes files as input
shareData.title = "Bits and pieces"
navigator.share(shareData)
.then(() => console.log('Share was successful.'))
.catch((error) => console.log('Sharing failed', error));
} else {
console.log("Your system doesn't support sharing files.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment