Notice: The Monaca & Onsen UI Community Forum is shutting down.
For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.
Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.
Geolocation blocked on browser
SInce yesterday, the access to geolocation on the preview pane stopped working on Chrome. The error is:
“Geolocation access has been blocked because of a Feature Policy applied to the current document. See https://goo.gl/EuHzyv for more details.”
It’s working on Android APK, though (at least for now)
It seems the problem is this in the preview page:
<iframe id=“PreviewFrame” src=""></iframe>
Iframe should have “allow=“geolocation *;””.
Not tested yet but I think access to camera, etc, will be also broken because of this.
Please fix this, without it’s impossible to preview apps that use location.
Thanks in advance!
@rcpinheiro That’s because there are some limitations while using Monaca Live Preview (the browser development interface) such as:
- Cordova Plugin APIs (such as Geolocation, Camera, …) are not available.
- Ajax requests will fail because of Cross-origin restriction. However, it can be done if server-side scripts return “Access-Control-Allow-Origin” Header (i.e., Cross-Origin Ajax Request is permitted).
- Viewport appearance may differ from real devices.
- Monaca Backend API and Push Notifications cannot be initialized.
Therefore, please test your project on Monaca Debugger.
I know all of that but it used to work until a couple of days ago.
The problem is easily fixed, just change the iframe statement. After all, geolocation is an HTML5 standard and it’s used on many websites, no need whatsoever for plugins or third-party libraries.
Fast and easy testing on the browser is Monaca’s best quality so it’s a major letdown having to use real devices just because it uses location specially when this could be easily fixed on your side, as I said.
@rcpinheiro We’ve added the iFrame’s attribute settings to allow the access of Geolocation, Microphone and Camera. This should fix your issue. Thanks for your suggestion. :bow:
@khemry Great, many thanks!