Web Share API permission missing

For other future users where the current answer is too specific to that code. The root issue is that the share() method must be called from a user gesture.

If the method call was not triggered by user activation, return a promise rejected with with a "NotAllowedError" DOMException. From the Web Share API.


A user activation is any of the following:

  • change
  • click
  • contextmenu
  • dblclick
  • mouseup
  • pointerup
  • reset
  • submit
  • touchend

I understood what was the issue, which is absolutely annoying.

So:

  const id = await shareRepository.shareTrip(this.props.todolist)

This call is the one that is causing problems. If I comment it, on iOS there is no issue.

If I keep it I have no problem at all on Android but iOS will complain.

So I need to rethink the flow of the application to pass the id from outside the 'onClick' event.

Tags:

Javascript