I have a web page that I'm loading in Safari on iOS 13.4.1. The web page calls DeviceOrientationEvent.requestPermission() and in the .catch following the .then I'm seeing this error:
NotAllowedError: Requesting device orientation or motion access requires a user gesture to prompt
However there is no pop-up requesting permission.
Does anyone know what I'm missing?
Late reply, hoping it might be useful to others.
The call
DeviceOrientationEvent.requestPermission()in your code must be performed as a reaction to some user gesture.So e.g. you would show a dialog to user with a message and a button, explaining what's going to happen next. In button click handler, you hide the dialog and actually call that method.
An example of click handler is given here: https://dev.to/li/how-to-requestpermission-for-devicemotion-and-deviceorientation-events-in-ios-13-46g2 .