6

I'm trying to get user location inside a Facebook Messenger Chat-Extension. I open the webview and ask as usual :

var options = {
  enableHighAccuracy: true,
  timeout: 5000,
  maximumAge: 0
};

function success(pos) {
  var crd = pos.coords;

  console.log('Your current position is:');
  console.log(`Latitude : ${crd.latitude}`);
  console.log(`Longitude: ${crd.longitude}`);
  console.log(`More or less ${crd.accuracy} meters.`);
};

function error(err) {
  console.warn(`ERROR(${err.code}): ${err.message}`);
};

navigator.geolocation.getCurrentPosition(success, error, options);

I'm getting this issue : ERROR(1): User denied Geolocation.
Is there a way to get user location through Chat Extension Webview ? Thank you

Pablo DelaNoche
  • 677
  • 1
  • 9
  • 28
  • Any updates on this question? I managed to make it work within Messenger with similar code, but with the Facebook website, I get the error message `Geolocation has been disabled in this document by Feature Policy.` – Željko Šević Oct 18 '20 at 13:42

1 Answers1

0

geolocation should work fine on most iOS devices, but will fail on most (if not all) Android devices. That said there is no cross-platform solution for retrieving a user's geo location properly within a webview or Chat extension.

lars.schwarz
  • 1,276
  • 1
  • 8
  • 12