Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS devices workaround? #71

Open
gavan1 opened this issue Jul 7, 2020 · 2 comments
Open

IOS devices workaround? #71

gavan1 opened this issue Jul 7, 2020 · 2 comments

Comments

@gavan1
Copy link

gavan1 commented Jul 7, 2020

Hello all, this was a great effect while...while it worked on IOS devices.

I’m surprised there has been no comment on this being non-functional across all IOS devices.

@MrUltimate
Copy link

+1 Would like to know this as well

@iltimasd
Copy link

iltimasd commented Jan 28, 2021

Hi all,

I'm working on a project right now, and managed to get DeviceMotion approval flow working.

this function must be triggered as a result of user interaction!!

This triggers a pop-up on iOS. Once the user grants permission, this library (and in theory all subsequent DeviceMotion calls) should work.

function clickHandler() {
try {
      //try block bc Safari
      if (typeof DeviceMotionEvent.requestPermission === "function") {
        DeviceMotionEvent.requestPermission()
          .then((permissionState) => {
            if (permissionState === "granted") {
              window.addEventListener("devicemotion", (e) => {
                console.log(e);
              });
            }
          })
          .catch(console.error);
      } else {
        // handle regular non iOS 13+ devices
      }
    } catch (e) {}
}

I threw in the try block because Safari of all browsers fails to call DeviceMotionEvent iirc

I don't have the moment to test but you might be able to get away with just calling DeviceMotionEvent.requestPermission()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants