Bug 213966
| Summary: | ios safari doesn't call deviceorientation event | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Giorgi <giorgi.lagidze> |
| Component: | WebKit Website | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED INVALID | ||
| Severity: | Blocker | CC: | cdumez, jond, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 13 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Giorgi
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/65203472>
Chris Dumez
Which build of iOS are you on?
Chris Dumez
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
My Bad, Chris. I was testing it from Simulator... All good. We can close this issue.
Chris Dumez
Good.