简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM