iOS Safari does not respect URL provided via Web Share API (Navigator.Share(data)))

Hi Apple developers,

I am building a web application (HTML/CSS/Javascript) which can be installed on any site. I would like to use the Web Share API to enable users to easily share a link to my application. Specifically I am using the Navigator.share(data) method (https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share)

I am however running in to a number of issues on iOS and Safari, that I hope someone here can help answer, as I have not been able to find documentation, that supports/explains my findings.

URL with query string parameters

Let's assume my application is executing on domain-x.com.

Using Navigator.share(data) I try to share a URL with query string parameters (simplified sample).

onShareButtonClick(event) {
    Navigator.share({ 
        url: "https://domain-x.com?somevariable=xyz", 
        title: "Some Title"
    });
}

When clicking the button which is hooked up to the eventhandler above, the share dialogue opens up correctly, but if I select sending via any message platform like Messenger, iMessage or other, the link being shared is without the query string - just https://domain-x.com.

However if I click the Copy button, the full URL (https://domain-x.com?somevariable=xyz) is copied.

URL different from application domain

Let's assume my application is executing on domain-x.com.

Using Navigator.share(data) I try to share a URL with another domain - domain-y.com (simplified sample).

onShareButtonClick(event) {
    Navigator.share({ 
        url: "https://domain-y.com/some-page", 
        title: "Some Title"
    });
}

When clicking the button which is hooked up to the eventhandler above, the share dialogue opens up correctly, but if I select sharing via any message platform like Messenger, iMessage or other, the link being shared is to the current page URL - eg. https://domain-x.com/current-page - not https://domain-y.com/some-page.

However if I click the Copy button (again), the correct URL (https://domain-y.com/some-page) is copied.

Do anybody know if this is the expected behavior on iOS? The share functionality works as expected on Android devices.

I am thinking Apple is removing the query string parameters as part of their privacy initiatives. Is removing the ability to share URL's with other domains than the application is running on part of a similar strategy?

Please help me with links or insights as to why this is happening - links to documentation or other forum posts are much appreciated - or am I simply doing something wrong?

Thanks a lot in advance :)

Thank you for posting this. I have been having similar issues as you described above. Hoping someone from apple will reply soon.

Did you ever find a solution? I am having the same issue.

Hi @kim_appstract. I figured it out. Use "text" instead of "url" as the value type in navigator.share.

Hi @kim_appstract, did you try using 'text' instead?

I'm facing the same issue and neither 'text' or 'url' is working. In my case the url does not have and query params, just a string of random characters. (e.g. domain-x.com/fc943abb-be22-4587-b006-f02392f7459b). Using navigator.share the url is shared successfully in iOS / Safari when sent via AirDrop, email, notion, etc., just not through Messages.

Just an FYI try using the the text option and put an extra space character at the end of the URL. That solved any residual issues we were having with messages not capturing the full URL

Hi,

I try different solutions, but don't work! It's crazy to see that the error still hasn't been corrected after so many months... It's Apple!

const data = { title: this.merchant.name, text: 'https://google.fr ', // url: 'https://google.fr', } try { await navigator.share(data) } catch (e) { console.log('share error', e) }

iOS Safari does not respect URL provided via Web Share API (Navigator.Share(data)))
 
 
Q