M
M
Marina2020-08-07 22:38:48
JavaScript
Marina, 2020-08-07 22:38:48

How to get gyroscope data on iOS?

You need to create a similar effect on js. There are no issues with android, on Safari iOS, as far as I know, they limited the receipt of gyroscope data. But maybe someone faced similar and know some solutions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Marina, 2020-10-15
@Mo_Ginger

As a result:
in Safari, without the permission of the browser, you cannot get gyroscope data.
The solution was to call the request window like this:

btn.onclick = function(e) {
  DeviceMotionEvent.requestPermission().then(response => {
    if (response == 'granted') {
      window.addEventListener('devicemotion', (e) => {
        /* разрешение получено */
    })
  }}).catch(console.error)
}

Hope it helps someone someday.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question