PWA Webshare iOS 12.3


#1

Hi Guys,

Trying to implement Webshare in PWA App, however it does not seem to work. iOS 12.2 implemented the feature.

I found this article.

Which also has a demo web page to test feature. Test page works on iPAD iOS 12.3
https://wicg.github.io/web-share/demos/share.html

The simple command is navigator.share({title, text, url}) nothing happens

Any ideas?

Ian.


#2

Just tried it here and it worked fine:

http://www.nsbasic.com/i/Share

JavaScript:

Button1.onclick = function() {
  args = {};
  args.title = "The Title";
  args.text = "The message";
  args.url = "https://example.com";
  navigator.share(args);
};

Basic:

Function Button1_onclick()
  args = {}
  args.title = "The Title"
  args.text = "The message"
  args.url = "https://example.com"
  navigator.share(args)
End Function


#3

Thank you, however running my app through the Web Inspector of MAC OS connecting my IPAD, I get this error.

[Error] Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
(anonymous function)
rejectPromise
share

any ideas

Ian.


#4

Do you get the same message running my app?

http://www.nsbasic.com/i/Share


#5

Yes it does.

I have found the error. You cannot run it within a function - outside the scope of an onclick event.

e.g.

function iosWebShare() {
 args = {};
  args.title = "The Title";
  args.text = "The message";
  args.url = "https://example.com";
  navigator.share(args);
};

call this function outside an click event say from another function.

You get the error.

Hope that makes sense.

Ian.


#6

@ianResearch you’re saying that if you call the defined function iosWebShare() outside of an event handler, that you get a permission error?


#7

Thats correct.

Seems odd.


#8

When are you calling iosWebShare? Could it be before all the loading is done?

If you take a look at the demo you cited in your original message, the indirect call is done after a delay.


#9

Calling in a menu option selection.

But I am going to do more testing, I can get it to work if i include a button and code in the button onclick all fine but if i call a function containing the code from the menu selection does not work.

I will get back to you once I have done some more checking.

Thank you

Ian.