Is it possible to get location from Messenger Webview
Asked Answered
K

1

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

Kishke answered 4/5, 2017 at 12:13 Comment(1)
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.Pissarro
C
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.

Coinsure answered 25/6, 2019 at 14:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.