Detect whether Motion & Orientation Access is enabled in Javascript - iOS

别来无恙 提交于 2019-12-31 03:45:08

问题


Unfortunately Safari disables Motion and Orientation access by default in:

Settings > Safari > Privacy & Security > Motion & Orientation Access

So what I'm trying to figure out is if it's possible to detect whether the user has this setting enabled or not. Is there a property on the window object in the browser that informs me that it's enabled?

I've tried looking up the solution on StackOverflow and various other places but they're either outdated or just don't work.


回答1:


You could use the window.orientation property (output will be in degrees), since it is supported in Safari for IOS

Note: Its use is depreciated and is not supported in many of the other browsers, fore other browsers you should use the screen.orientation property or the Generic Sensors API



来源:https://stackoverflow.com/questions/56533863/detect-whether-motion-orientation-access-is-enabled-in-javascript-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!