[Solved] Sensor support IOS13+ stopped working

Dear all,

Did anybody notice that since a few weeks with the release of IOS13 the motion HTML games do not work anymore? After digging tonight I found this How to requestPermission for devicemotion and deviceorientation events in iOS 13+ - DEV Community It indeed solves the problem but only with an on click event from a button. I tried to add this from JavaScript but not successful. I’m not able to click the button because it seems to be behind the scene. However I think it is far more professional to ask the HTML5 game player in boot of the game to give consent for sensors and location. Is it possible to add this?

Many thanks.

You could make a button click here to start the game that does your thing then adds the scripts tags from GDevelop and the game (using Dom)

Yes I tried this using the code below. Button apperas but cannot click it. It seems to be in the background. Jave Code that runs at the start of the scene (TextBox is a text object):

const MessageBoxText=runtimeScene.getObjects(“TextBox”);
MessageBoxText[0].setString(“rotateZ”);
var btn = document.createElement(“BUTTON”); // Create a element
btn.innerHTML = “CLICK ME”; // Insert text
btn.id=“request”;
btn.onclick = function requestT () {
if (typeof(DeviceMotionEvent) !== ‘undefined’ && typeof(DeviceMotionEvent.requestPermission) === ‘function’) {
alert(‘enter’);
DeviceMotionEvent.requestPermission()
.then(response => {
alert(‘resp’+ response);
if (response == ‘granted’) {
window.addEventListener(‘devicemotion’, (e) => {
// do something with e
var alpha = e.alpha,
beta = e.beta,
gamma = e.gamma;

      // Rotate the <img> element in 3 axes according to the device’s orientation
              MessageBoxText[0].setString("rotateZ(" + alpha + "deg) rotateX(" + beta + "deg) rotateY(" + gamma + "deg)");
            })
          }
        })
    .catch(console.error)

}else {
alert(‘DeviceMotionEvent is not defined’);
}
};
document.body.appendChild(btn); // Append to

OK, I did this. Made an HTML page with the permission and after that i point to index.html of the ballgame example on my own https server. However no movement of the ball which worked a month ago. So the game works, but somehow I need to enable something I guess.

Fixed the problem. Send PM if you want to have it

Solved. Edited the index.html of the game itself

That is literally what I told you to do

yes, but I did not understand since I’m a GDevelop user not a HTML wizard:) I also hoped to do it more elegant because in this case I must apply the changes every time I compile the game. However there are more important issues to solve. However would be nice to have it in the default game set-up. Thanx again

What did you literally told him to do? Because i can’t find what to do in this topic.