Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 12.2: device orientation data still blocked even after manual enabling in settings

With iOS 12.2 Apple has blocked access to device orientation data by default. This must be enabled manually now (-__-), as explained here.

The thing is, even after enabling "Motion & Orientation Access" in settings, I got this warning message on Safari debugger when I try to set a listener on deviceorientation event:

function onDeviceOrientationChange (e) {
    console.log(e)
}

window.addEventListener("deviceorientation", onDeviceOrientationChange, false);

// ---> Blocked attempt to add a device motion or orientation listener because the browsing context is not secure.

I am developing on webpack dev server. How can I get rid of this block and access device orientation data as before?

like image 215
revy Avatar asked Apr 15 '19 21:04

revy


1 Answers

I had the same issue recently. Turns out you need HTTPS enabled to access this information. As soon as I enabled HTTPS it worked fine.

like image 59
Scott Harrison Avatar answered Sep 29 '22 11:09

Scott Harrison