user2335065
user2335065

Reputation: 2557

Can I open the native Android Share Dialogue when building app using WebView?

This article tells me it can be done while this says it's not possible at all. Am I reading the links wrongly? What is the most effective way to have a share button on a webapp built by WebView?

Upvotes: 1

Views: 2357

Answers (1)

shivendra pratap singh
shivendra pratap singh

Reputation: 1398

You can share using android default share bottom sheet. use the following component.

if (navigator.share) {
    navigator.share({
    title: 'Web Fundamentals',
    text: 'Check out Web Fundamentals — it rocks!',
    url: 'https://developers.google.com/web',
})
    .then(() => console.log('Successful share'))
    .catch((error) => console.log('Error sharing', error));
}

This provides native sharing experience on Android devices while using web. Native android share

Upvotes: 2

Related Questions