iOS Question WKwebview motion and orientation permission

stevenindon

Active Member
Licensed User
Hello there,

How can i request permission for "motion and orientation permission" in a WKwebview?

I have this in my #PlistExtra but did not work :

#PlistExtra:<key>NSMotionUsageDescription</key><string>Request Motion event</string>

Please find attached image - Safari accessing to the html which requires the 'motion and orientation permission'
 

Attachments

  • Permission.jpg
    158.4 KB · Views: 156
Last edited:

stevenindon

Active Member
Licensed User
After much of reading, I found that the html executes request permission for "Access Motion and Orientation" through javascript as below :

B4X:
<script type="text/javascript">
    function requestOrientationPermission(){
        DeviceOrientationEvent.requestPermission()
        .then(response => {
            if (response == 'granted') {
                window.addEventListener('deviceorientation', (e) => {
                    // do something with e
                })
            }
        })
        .catch(console.error)
    }
</script>

<button onclick='requestOrientationPermission();'>Request orientation permission</button>

When i run above html/javascript page using safari or chrome...and click on button, it pops up request permission for "Access Motion and Orientation". But when i run on WKwebview, there is no pop up for permission request.

You may test above html/javascript here : https://www.techiesworld.net/Permission.asp

Trying to solve this. Some in other forum claims we can solve this by : webView.uiDelegate = self
but i cant find such command in WKWebview.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…