In iOS 12.2 Apple removed the motion sensors by default from mobile Safari. Chrome did something similar recently too. In iOS 13, a requestPermission popup was added back.
.then(response => {
if (response == 'granted') {
window.addEventListener('devicemotion', (e) => {
// do something with e
})
}
})
.catch(console.error)
This solution works great for mobile browsers, and those are now working.
I'm hitting issues now on non-mobile browsers (Edge Chromium, and Chrome)
Uncaught TypeError: window.DeviceMotionEvent.requestPermission is not a function at game.start_handling (game.js:706)
I'm assuming I need to do some sort of check if the method/function exists before calling it. Any suggestions?
My current solution is to do a check if the browser is mobile. This works, but I feel like there is probably a better way.