GDevelop
GDevelop copied to clipboard
Add an action to request permission to device sensors on iPhones
Description
The existing device sensor conditions and actions do not work on iPhones running new versions of IOS (13+).
Solution suggested
- Add an action to request permission to device sensors on iPhones
Background
How to request permission for devicemotion and deviceorientation events in iOS 13+
https://dev.to/li/how-to-requestpermission-for-devicemotion-and-deviceorientation-events-in-ios-13-46g2
How 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
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:
https://aframe.io/examples/
Source:
https://github.com/aframevr/aframe/blob/master/src/components/scene/device-orientation-permission-ui.js