Tuesday, 16 July 2019

Blocked JS deviceorientation devicemotion on Android WebView

I've written a JS SDK for Android WebView that collects device orientation and motion. The SDK listens to deviceorientation and devicemotion events on the window like so:

window.addEventListener('devicemotion', (event) => {...})
window.addEventListener('deviceorientation', (event) => {...})

On some devices/integrations, I get no sensors data. I've tried to mimic a "bad" integration, attempting to block the WebView sensors access by adding the following to the app manifest but with no luck. The JS events are still triggered:

<activity
    android:screenOrientation="portrait"
    android:configChanges="keyboardHidden|orientation|screenSize"

What are other possible ways to block the WebView from triggering the events, besides disabling JS all together?



from Blocked JS deviceorientation devicemotion on Android WebView

No comments:

Post a Comment