Is it possible to create a share button (link) in my website that can invoke share dialogs in iOS and Android systems?
I mean the following dialog for each system:
I am not asking of how to do it by using iOS/Android SDKs. I want it with only HTML/JavaScript.
The navigator. share() method of the Web Share API invokes the native sharing mechanism of the device to share data such as text, URLs, or files. The available share targets depend on the device, but might include the clipboard, contacts and email applications, websites, Bluetooth, etc.
The Web Share API allows a site to share text, links, files, and other content to user-selected share targets, utilizing the sharing mechanisms of the underlying operating system. These share targets typically include the system clipboard, email, contacts or messaging applications, and Bluetooth or Wi-Fi channels.
Web sharing (also known as "screen sharing" and "desktop sharing") is a software function that allows a stream of data to be shared across the Internet to one or more devices. While the term can refer to the exchange of any kind of data, usually it refers to shared screen and audio data.
It is supported by
$('#answer-example-share-button').on('click', () => {
if (navigator.share) {
navigator.share({
title: 'Web Share API Draft',
text: 'Take a look at this spec!',
url: 'https://wicg.github.io/web-share/#share-method',
})
.then(() => console.log('Successful share'))
.catch((error) => console.log('Error sharing', error));
} else {
console.log('Share not supported on this browser, do it the old way.');
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button id='answer-example-share-button'>Share!</button>
Citing Google Developers:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With