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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With