0

I have a chrome app with permissions set one of which is geolocation. It have a sandbox index.html I want to get user location from that index.html. Is there any way I can get geolocation from that page.

function success(position){

}
function error(){
  console.log('unable to track user location now')
}
var id = navigator.geolocation.watchPosition(success, error, options);

gives error user denied location. I did not see pop up this page is requestiong geolocation permisison

Node Mario
  • 179
  • 13
  • It's always possible to use messaging to the main window which will access the API and post the results back. – wOxxOm Sep 01 '16 at 07:26
  • That is what I am doing right now. Was looking for a better solution say I am tracking the user location continuously is it ok to fire so many post to get current location – Node Mario Sep 01 '16 at 07:56

1 Answers1

0

The sandbox does not get the privileges that the app is granted (that's exactly the point of a sandbox), and the Chrome App UI does not allow permission prompts.

Therefore, a sandboxed page can never get that permission. You will need to perform geolocation from a non-sandboxed page and communicate with the sandbox.

Xan
  • 74,770
  • 16
  • 179
  • 206