immersive-web / cardboard-vr-display

A JavaScript implementation of a WebVR 1.1 VRDisplay
https://immersive-web.github.io/cardboard-vr-display
Apache License 2.0
91 stars 43 forks source link

iPhone iOS 13 requires permission request for devicemotion/orientation #40

Open richardtallent opened 4 years ago

richardtallent commented 4 years ago

For Safari under iOS 13, the devicemotion and deviceorientation events aren't available without explicit permission from the user, which must be requested in the code before adding the listener. As a result, I can't get anything but a 45-degree still image to show up in the cardboard viewer.

Here's a related article:

https://dev.to/li/how-to-requestpermission-for-devicemotion-and-deviceorientation-events-in-ios-13-46g2

danrossi commented 4 years ago

Confirming there is no such feature. And gets worse. IOS 13 supports fullscreen. But the request has to be on a user click and not in a fullscreen callback, it complains about needing user click.

When going fullscreen the notification is hidden by the fullscreen element. Just ridiculous.

Therefore it has to be made before triggering fullscreen within the promise callback. And then fullscreen fails the first time. Second time it magically works.

Only fix. Or trigger this capturing a user click for the application. It will store the request and not popup a notification. On reload orientation works without request.

window.DeviceOrientationEvent.requestPermission().then( function ( response ) {
                        console.log("SUCCESS", response);
  if ( response == 'granted' ) { 
     //request session / present
  }

});