navigator.permissions.query not working in android

2019-09-04 15:31发布

问题:

I need to check for geolocation permissions and update status after prompt in webview. The permissions api query works in web browsers but not in webviews of android or ios.

Working in Browsers : navigator.permissions.query({name:'geolocation'})

Android/iOS Web views navigator.permissions is undefined.

回答1:

I have suspicion that it's by design to not mix web permissions with OS app permissions which have different granularity when WebView is bundled inside an app.

For example:

  • giving app permission to location should not allow WebView to grant location permission to all websites/ origins it may open.
  • allowing origin xyz.com permission to use camera should not grant app permission either