1

I want to implement mobile device "shake" event both for Android and iOS platforms on my webpage.

So, I immediately found one and only script written by Alex Gibson.

After some tests I found out that it works on Android phone perfectly. On iPhone it doesn't work unfortunately.

According to MDN web docs it's nothing wrong with the script which uses devicemotion event.

This script on codeopen with no errors for iOS, just not working.

Is there any approach to overcome this issue?

U.P.D.

I found this article describing requirements for iOS 13 for devicemotion event, so now you have to request permission for it.

But it also doesn't work.

window.DeviceMotionEvent.requestPermission()
  .then(response => {
    console.log(response);
  }
})

It returns 'denied' status anyway without any permission request.

mr.boris
  • 3,667
  • 8
  • 37
  • 70

1 Answers1

3

I ran into this problem too. requestPermission for the devicemotion event is always denied (silently) by iOS 13+, but only if you are running your site on http.

It worked (for me at least) if I ran my site on https.

donald_i
  • 41
  • 3