RESOLVED INVALID213966
ios safari doesn't call deviceorientation event
https://bugs.webkit.org/show_bug.cgi?id=213966
Summary ios safari doesn't call deviceorientation event
Giorgi
Reported 2020-07-04 16:39:51 PDT
Hi Safari Team... I am trying to use `deviceorientation` event to be called. The problem is it doesn't get called. I know that I should request permission to be able to listen to that event. Here is the code I am using .. <html> <button onclick="test()">click here</button> <script> function test(){ DeviceOrientationEvent.requestPermission() .then(response => { if (response == 'granted') { console.log("granted good"); window.addEventListener('deviceorientation', (e) => { // do something with e console.log("device orientation changed ", e); }) } }).catch(err => { console.log("Err ", err); }) } </script> </html> It logs `granted good` , but when I change orientation, it never logs the below log nor the error. To reproduce the above thing, go to https://glagidze.com/index1.html Questions: 1) Why doesn't it log when orientation changes ? 2) Will this work for below IOS versions (even after requesting permission ? ) 3) What other solutions (if this doesn't work) should I provide ? (window.orientation looks like it's working, but it's deprecated). Thanks in advance..
Attachments
Radar WebKit Bug Importer
Comment 1 2020-07-07 18:50:13 PDT
Chris Dumez
Comment 2 2020-07-08 08:53:40 PDT
Which build of iOS are you on?
Chris Dumez
Comment 3 2020-07-08 08:56:01 PDT
If I go to https://glagidze.com/index1.html on iOS 14 beta, I see the permission prompt, then plenty of alerts with the orientation (that is different every time). Seems to work as expected for me.
Giorgi
Comment 4 2020-07-08 16:34:22 PDT
My Bad, Chris. I was testing it from Simulator... All good. We can close this issue.
Chris Dumez
Comment 5 2020-07-08 16:38:21 PDT
Good.
Note You need to log in before you can comment on or make changes to this bug.