Open tristanbob opened 1 year ago
Hi @tristanbob and thank you for taking the time to look into solutions for this! The solution you found seems to be supported by Safari on iOs only (https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent#browser_compatibility) CanIUse is more optimistic though: https://caniuse.com/?search=requestPermission
I wonder if this issue occurs on Android smartphones as well. Do you have a game example that I could use to test on my Android?
@AlexandreSi there are a couple game examples already inside GDevelop that you can test with. Search for "device sensor".
The external example I linked to worked on my Safari and Chrome browser, so it feels like it should work for most users.
Any updates on this? I'd love to make games with this feature.
https://x.com/victrisgames/status/1697456638477881651?s=46&t=ez41cYT0tq4QuAag1Dbrcg
I found the source to website that does a good job with this:
Source:
Description
The existing device sensor conditions and actions do not work on iPhones running new versions of IOS (13+).
Solution suggested
Background
How to request permission for
devicemotion
anddeviceorientation
events in iOS 13+ https://dev.to/li/how-to-requestpermission-for-devicemotion-and-deviceorientation-events-in-ios-13-46g2How to Request Device Motion and Orientation Permission in iOS 13 https://leemartin.dev/how-to-request-device-motion-and-orientation-permission-in-ios-13-74fc9d6cd140
Working example
This example worked on my iPhone 12 running IOS 15, in both Chrome 107 and Safari. https://kongmunist.medium.com/accessing-the-iphone-accelerometer-with-javascript-in-ios-14-and-13-e146d18bb175