0

Hello i am creating an application using google nearest places api, which will enable me show the nearest places around a location.

the application works without any errors when tested on a normal web browser or chrome mobile browser as screen shot below

Please click to view

The issue i encounter is when i run this web application via an inapp browser or crosswalk webview plugin for cordova i am unable to get my present location (geolocation dosent work)

Please how can i get my web app get its present location using geolocation via either the crosswalk or inappbrowser

i presume this is an issue of geolocation permissions but i dont know how to solve this

chap man
  • 37
  • 6

1 Answers1

0

If this is issue du to geolocation permissions was missed you can use this plugin for check if there are enable, ask to user to enable it, check if you have the permissions to use geolocalisation and if not, ask the permissions to user :

https://github.com/dpa99c/cordova-diagnostic-plugin

function isAuthorize() {
    cordova.plugins.diagnostic.isLocationAuthorized(function(authorized){
        if (authorized) {
            this.isEnabled();
        }
        else {
            // Do something whenuser don't allowed the localisation
        }
    }, function(error){
        console.error("The following error occurred: "+error);
    });
}

function isEnabled() {
    cordova.plugins.diagnostic.isLocationEnabled(function(enabled){
        if (enabled) {
            // Geolocation is enabled and you have permission to used it
        }
        else {
            // Geolocalisation is not enabled
            // Displays the device location settings to allow user to enable location services/change location mode.
            cordova.plugins.diagnostic.switchToLocationSettings();
        }
    }, function(error){
        console.error("The following error occurred: "+error);
    });
}
Enzo B.
  • 2,341
  • 1
  • 11
  • 33
  • ok thank u, but i also noticed this issue when i tested the web app on my mobile browser, but when i used another mobile browser like chrome the location got picked up, could this problem be with my mobile webview or something? – chap man Jul 26 '18 at 15:25