Page 1 of 1

iOS get permisson for motion sensors

Posted: Mon Dec 16, 2019 3:00 pm
by Dirk Geppert
Since iOS 13 it is necessary, to get the permissions from user to be authorized to interrogate the motion sensors.
Otherwise things like VR view and Babylon will not work anymore..
I found an working javascript example @

But how can I integrate this as a function in spiderbasic?

Code: Select all
window.onload = function () {

  // Check if is IOS 13 when page loads.
  if ( window.DeviceMotionEvent && typeof window.DeviceMotionEvent.requestPermission === 'function' ){

      // Everything here is just a lazy banner. You can do the banner your way.
      const banner = document.createElement('div')
      banner.innerHTML = `<div style="z-index: 1; position: absolute; width: 100%; background-color:#000; color: #fff"><p style="padding: 10px">Click here to enable DeviceMotion</p></div>`
      banner.onclick = ClickRequestDeviceMotionEvent // You NEED to bind the function into a onClick event. An artificial 'onClick' will NOT work.

function ClickRequestDeviceMotionEvent () {
    .then(response => {
      if (response === 'granted') {
          () => { console.log('DeviceMotion permissions granted.') },
          (e) => { throw e }
      )} else {
        console.log('DeviceMotion permissions not granted.')
    .catch(e => {

Any help is welcome!

Re: iOS get permisson for motion sensors

Posted: Wed Dec 18, 2019 10:09 am
by Dirk Geppert
If no one can help with the SB integration.
It works at least as pure Javascript.
The code generates a clickable banner and an onClick unlocks the sensors.

How can I remove this button/banner?

Just to delete the banner child does not work.. :?

Code: Select all

Re: iOS get permisson for motion sensors

Posted: Wed Dec 18, 2019 12:17 pm
by Dirk Geppert
Even better: A-Frame has it now directly in the framework :D