arnellebalane
4/5/2017 - 3:34 AM

web share api demo

web share api demo

// progressive enhancement, use it only when it is available
if ('share' in navigator) {

    // the object argument to navigator.share() should have at least
    // one of the following keys: title, text, url
    navigator.share({
        title: 'The Web Share API',
        text: 'The text that I want to share',
        url: 'https://blog.arnellebalane.com/the-web-share-api'
    })
    .then(() => console.log('Sharing successful'))
    .catch((error) => console.log('Sharing failed'));
}