Giter Site home page Giter Site logo

Comments (70)

dragonfast avatar dragonfast commented on May 27, 2024 4

I'm using this plugin instead:
cordova plugin add https://github.com/ToniKorin/cordova-plugin-location-provider.git
this plugin using LocationProvider natively, not W3C API and work on vivo, oppo, xiaomi.

cordova.plugins.LocationProvider.getOwnPosition(param like w3C, successcallback, errorcallback)

from cordova-plugin-geolocation.

vudq avatar vudq commented on May 27, 2024 3

I have the same issue. Did anyone already find a solution?
8536c9957bdba285fbca

from cordova-plugin-geolocation.

deepakpapney avatar deepakpapney commented on May 27, 2024 3

facing the same issue from the last 2-3 days, Does anyone knows how to fix it? previously it was working fine.?????

from cordova-plugin-geolocation.

ajaybhakar avatar ajaybhakar commented on May 27, 2024 3

Tried but still not working even after restarting the device.

from cordova-plugin-geolocation.

gohrms avatar gohrms commented on May 27, 2024 3

It will be helpful if the issue is kept open to get more ideas and solution from people.

from cordova-plugin-geolocation.

atmanegara avatar atmanegara commented on May 27, 2024 2

Most likely will be fixed when #250 is fully released.

If you could test the development version of the plugin and provide feedback, that would be great.

cordova plugin remove cordova-plugin-geolocation
cordova plugin add https://github.com/apache/cordova-plugin-geolocation.git

Just a reminder that development versions haven't been voted on or tested for release, so the build should not be used in production environments.

yes, we have installed this plugin, the location application is still not found,
but if via the browser on the oppo/vivo device it works fine,
the general syntax we use

const options = {
      enableHighAccuracy: true,
      timeout: 5000,
      maxAge: 0
    };
    
    function success(pos) {
      const 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);

is there a problem in webview cordova for vivo/oppo devices?

from cordova-plugin-geolocation.

prabusharan avatar prabusharan commented on May 27, 2024 2

facing the same issue from the last 2-3 days, Does anyone knows how to fix it? previously it was working fine.?????

from cordova-plugin-geolocation.

utk4rsh92 avatar utk4rsh92 commented on May 27, 2024 2

facing geolocation fetch problem from past 3-4 days for Vivo device Funtouch(Android 12) OS, anyone have solution for this?

from cordova-plugin-geolocation.

breautek avatar breautek commented on May 27, 2024 2

is there a problem in webview cordova for vivo/oppo devices?

Here is what I know and don't know...

I do not know if there are device-specific issues. There is an issue on Android 12 devices regarding geolocation via the webview, which is still an open issue. This is a webview bug, not something that Cordova can deal with directly. The bug has to do with attempting to request strictly coarse location. Effectively with this bug, enableHighAccuracy must be true and the application must have the FINE location permission.

#250 works around that issue by asserting that fine location is always enabled on Android 12+ devices, additionally it also treats both permission levels independent as now recommended by Android 12 location changes.

Now, based on the comments so far, it seems like whatever has happened in the last 3-4 days as many pointed out so... this does not seem to be related to that issue. Cordova hasn't released anything that would have broken this runtime (#250 have been merged in, but it isn't released). Presumably these developers also haven't made any updates to their app that would have caused a difference in their geolocation code. With these assumptions, the only thing that can update and cause difference in behaviour in their app is the system webview, which was updated on Nov 14. Giving time to publish and end users to update their device with the latest version (107.0.5304.105), the timeline probably fits.

What I would suggest is attempting to reproduce the issue with a stripped down sample application and raise an issue with Google Chromium team. They will expect an APK and the full source code of the reproduction app.

from cordova-plugin-geolocation.

jubinpatel avatar jubinpatel commented on May 27, 2024 2

We are also strugling with same issue majorly with OPPO, VIVO, REDMI, MI devices Also for few rare cases in OLD LG/MOTO smartphones.
One thing I have observed most of them having WEBVIEW of 107.X.X version.

Onyone If you have found existing ticket or reported to Google, please share link here for refrence.

EDIT: few Android 9+ device also reported same issue, and strage behavior, sometime its working, sometimes not. BUT for OPPO/VIVO its not working for once.

from cordova-plugin-geolocation.

Mitesh-Abacus avatar Mitesh-Abacus commented on May 27, 2024 2

What was the solution? , because we have already had no update in our app for the last 2-3 months, but
suddenly the app not getting location, please suggest how can resolve this.

from cordova-plugin-geolocation.

Efrotech1234 avatar Efrotech1234 commented on May 27, 2024 2

Issue will be resolve, follow these instructions.

  1. Use this plugin which is free available on GitHub or npm.
    cordova-plugin-locationservices-fix
  2. In code use LocationServices instead of navigator.geolocation
    i.e. LocationServices.getCurrentPosition(,,)

from cordova-plugin-geolocation.

mobiliseapplabllp avatar mobiliseapplabllp commented on May 27, 2024 2

from cordova-plugin-geolocation.

atmanegara avatar atmanegara commented on May 27, 2024 1

yes till now (already 1 week), i have the same problem, not only vivo devices but also oppo,
I got the information from the user, after updating the system on the device, between October and November, the geolocation can't be used anymore (request timeout), (GPS/or Google maps work fine), debugging via Android studio also doesn't show any problems, but samsung or xiaomi devices are fine on android 12

from cordova-plugin-geolocation.

mobiliseapplabllp avatar mobiliseapplabllp commented on May 27, 2024 1

i am also facing the same issue last 2-3 days previously it was working fine.
one plus nord can't get location i already update plugin but problem not resolved
samsung, realme, redmi working fine but one plus nord and many client phone can't get access location

"cordova-plugin-geolocation": "^4.1.0",
"@ionic-native/geolocation": "^5.36.0",

from cordova-plugin-geolocation.

Mr-Jeeva avatar Mr-Jeeva commented on May 27, 2024 1

Can anyone share the repository of the custom plugin with the native code? We would like to test the same in our application. We are struggling with this issue in our application working for several thousand users.

I'm still working on it (Testing it on various devices). Once it completed. Will share it

from cordova-plugin-geolocation.

atmanegara avatar atmanegara commented on May 27, 2024 1

I'm using this plugin instead: cordova plugin add https://github.com/ToniKorin/cordova-plugin-location-provider.git this plugin using LocationProvider natively, not W3C API and work on vivo, oppo, xiaomi.

cordova.plugins.LocationProvider.getOwnPosition(param like w3C, successcallback, errorcallback)

solved, works very well

from cordova-plugin-geolocation.

deepakpapney avatar deepakpapney commented on May 27, 2024 1

getOwnPosition

giving error at plugins.Locationprovider???

from cordova-plugin-geolocation.

yaro08 avatar yaro08 commented on May 27, 2024 1

Worked for me: update Android WebView from Google Play store and uninstall Play services. After that I rebooted the phone.
Device: VIVO x80 pro android 13 and my app created with ionic 5 and cordova, now location service and geolocation work as expected.

from cordova-plugin-geolocation.

mobiliseapplabllp avatar mobiliseapplabllp commented on May 27, 2024 1

from cordova-plugin-geolocation.

amnuaycn avatar amnuaycn commented on May 27, 2024 1

I am using IONIC and change "cordova-plugin-geolocation" to @capacitor/geolocation it working

//import { Geolocation } from '@ionic-native/geolocation/ngx';
//import { LocationAccuracy } from '@ionic-native/location-accuracy/ngx';
import { Geolocation,PositionOptions } from '@capacitor/geolocation';
...
public options: PositionOptions = {
    timeout: 5000, 
    enableHighAccuracy: true, 
    maximumAge: 3000
  };
...

/*async getCurrentCoordinates() {
    this.geolocation.getCurrentPosition(this.options).then((resp) => {
      this.latitude = resp.coords.latitude;
      this.longitude = resp.coords.longitude;
      console.log('accuracy:',resp.coords.accuracy);
     }).catch((error) => {
       console.log('Error getting location', error);
     });
  }
*/
  async getCurrentCoordinates() {
    const position = await Geolocation.getCurrentPosition(this.options);
    console.log('accuracy:',position.coords.accuracy);
    this.latitude = position.coords.latitude;
    this.longitude = position.coords.longitude;
  }

from cordova-plugin-geolocation.

dsmalicsi avatar dsmalicsi commented on May 27, 2024 1

I'm using this plugin instead: cordova plugin add https://github.com/ToniKorin/cordova-plugin-location-provider.git this plugin using LocationProvider natively, not W3C API and work on vivo, oppo, xiaomi.

cordova.plugins.LocationProvider.getOwnPosition(param like w3C, successcallback, errorcallback)

This solution doesn't work for devices that doesn't have Google Play Services like Huawei. I hope anyone could share any alternative that they could find. Thanks!

Screenshot 2022-11-29 at 10 25 54 AM

from cordova-plugin-geolocation.

gohrms avatar gohrms commented on May 27, 2024 1

Seems like Android is playing games with IONIC and CORDOVA and making us inclined towards native technologies like Flutter. But mind you Android this is not the right way. Yes, any simple successful solution is highly appreciated, the users of the app are suffering because of these mess.

from cordova-plugin-geolocation.

enfield09 avatar enfield09 commented on May 27, 2024

did you find any solution?

from cordova-plugin-geolocation.

breautek avatar breautek commented on May 27, 2024

Most likely will be fixed when #250 is fully released.

If you could test the development version of the plugin and provide feedback, that would be great.

cordova plugin remove cordova-plugin-geolocation
cordova plugin add https://github.com/apache/cordova-plugin-geolocation.git

Just a reminder that development versions haven't been voted on or tested for release, so the build should not be used in production environments.

from cordova-plugin-geolocation.

vudq avatar vudq commented on May 27, 2024

Most likely will be fixed when #250 is fully released.

If you could test the development version of the plugin and provide feedback, that would be great.

cordova plugin remove cordova-plugin-geolocation
cordova plugin add https://github.com/apache/cordova-plugin-geolocation.git

Just a reminder that development versions haven't been voted on or tested for release, so the build should not be used in production environments.

We used the plugin from github just like you indicated but still can't get the location.

from cordova-plugin-geolocation.

mobiliseapplabllp avatar mobiliseapplabllp commented on May 27, 2024

facing geolocation fetch problem from past 3-4 days for Vivo device Funtouch(Android 12) OS, anyone have solution for this?

same problem did you find the solution

from cordova-plugin-geolocation.

Nhc007 avatar Nhc007 commented on May 27, 2024

@breautek We have been facing this same issue in OPPO, VIVO, REDMI, MI, OLD LG/MOTO Devices, Mostly having Android 12, If this issue is related with Android WebView even so, I tried downgrading and using the previous stable releases of it, but the issue still persists.
I'm confused that whether its android webview that is misbehaving or there is something else, as I've tried playing with different versions of it.

Edit: I've also posted on google android support community regarding webview.

from cordova-plugin-geolocation.

breautek avatar breautek commented on May 27, 2024

@breautek We have been facing this same issue in OPPO, VIVO, REDMI, MI, OLD LG/MOTO Devices, Mostly having Android 12, If this issue is related with Android WebView even so, I tried downgrading and using the previous stable releases of it, but the issue still persists. I'm confused that whether its android webview that is misbehaving or there is something else, as I've tried playing with different versions of it.

Edit: I've also posted on google android support community regarding webview.

I just wanted to add and make clear that this plugin doesn't actually implement any actual geolocation code for the android platform. What it does do is just handle the app permissions for geolocation.

So assuming this issue is not a permission issue and the app has all the relevant permissions, the next logical step to troubleshoot is the geolocation implementation itself, which is not implemented by Cordova.

from cordova-plugin-geolocation.

Mr-Jeeva avatar Mr-Jeeva commented on May 27, 2024

Found a workaround. Instead of using this plugin, can be fixed by writing custom plugin with native code (Location Manager or Fused Location).

from cordova-plugin-geolocation.

mobiliseapplabllp avatar mobiliseapplabllp commented on May 27, 2024

from cordova-plugin-geolocation.

utk4rsh92 avatar utk4rsh92 commented on May 27, 2024

Can anyone share the repository of the custom plugin with the native code? We would like to test the same in our application. We are struggling with this issue in our application working for several thousand users. From: jeeva @.> Reply to: apache/cordova-plugin-geolocation @.> Date: Thursday, 24 November 2022 at 10:05 AM To: apache/cordova-plugin-geolocation @.> Cc: ASHISH SHARMA @.>, Comment @.> Subject: Re: [apache/cordova-plugin-geolocation] Unable to fetch Location on VIVO Devices (Issue #255) Found a workaround. Instead of using this plugin, can be fixed by writing custom plugin with native code (Location Manager or Fused Location). — Reply to this email directly, view it on GitHub<#255 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKPRXN5PHUK4XNOO6D6ZSI3WJ3V4ZANCNFSM6AAAAAASGQFOLE. You are receiving this because you commented.Message ID: @.>

working with https://github.com/transistorsoft/cordova-background-geolocation-lt

from cordova-plugin-geolocation.

deepakpapney avatar deepakpapney commented on May 27, 2024

Can anyone share the repository of the custom plugin with the native code? We would like to test the same in our application. We are struggling with this issue in our application working for several thousand users. From: jeeva @.> Reply to: apache/cordova-plugin-geolocation _@**._> Date: Thursday, 24 November 2022 at 10:05 AM To: apache/cordova-plugin-geolocation _@.> Cc: ASHISH SHARMA @._>, Comment _@.> Subject: Re: [apache/cordova-plugin-geolocation] Unable to fetch Location on VIVO Devices (Issue #255) Found a workaround. Instead of using this plugin, can be fixed by writing custom plugin with native code (Location Manager or Fused Location). — Reply to this email directly, view it on GitHub<#255 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKPRXN5PHUK4XNOO6D6ZSI3WJ3V4ZANCNFSM6AAAAAASGQFOLE. You are receiving this because you commented.Message ID: @.**_>

working with https://github.com/transistorsoft/cordova-background-geolocation-lt

please share code if it working

from cordova-plugin-geolocation.

deepakpapney avatar deepakpapney commented on May 27, 2024

orks very well

can you please share the code and changes you did
....

from cordova-plugin-geolocation.

prabusharan avatar prabusharan commented on May 27, 2024

Can anyone share the repository of the custom plugin with the native code? We would like to test the same in our application. We are struggling with this issue in our application working for several thousand users. From: jeeva @.> Reply to: apache/cordova-plugin-geolocation _@**._> Date: Thursday, 24 November 2022 at 10:05 AM To: apache/cordova-plugin-geolocation _@.> Cc: ASHISH SHARMA @._>, Comment _@.> Subject: Re: [apache/cordova-plugin-geolocation] Unable to fetch Location on VIVO Devices (Issue #255) Found a workaround. Instead of using this plugin, can be fixed by writing custom plugin with native code (Location Manager or Fused Location). — Reply to this email directly, view it on GitHub<#255 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKPRXN5PHUK4XNOO6D6ZSI3WJ3V4ZANCNFSM6AAAAAASGQFOLE. You are receiving this because you commented.Message ID: @.**_>

working with https://github.com/transistorsoft/cordova-background-geolocation-lt

please share code if it working

This is paid plugin

from cordova-plugin-geolocation.

atmanegara avatar atmanegara commented on May 27, 2024

orks very well

can you please share the code and changes you did ....

const options = {
    enableHighAccuracy: false,
    timeout: 30000,
    maximumAge: 0
  };
  
  function success(pos) {
    const 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(err);
    console.warn(`ERROR(${err.code}): ${err.message}`);
  }
  
 // navigator.geolocation.getCurrentPosition(success, error, options);
 cordova.plugins.LocationProvider.getOwnPosition(options,success,error)```

from cordova-plugin-geolocation.

atmanegara avatar atmanegara commented on May 27, 2024

getOwnPosition

giving error at plugins.Locationprovider???

whether to use this plugin https://github.com/ToniKorin/cordova-plugin-location-provider.git

from cordova-plugin-geolocation.

jubinpatel avatar jubinpatel commented on May 27, 2024

OFF THE TOPIC: even we find solution with another paid plugin use, we stuck with another dead-end.
OUR based API is 30 and From YESTERDAY onwards GOOGLE play store not allow to submit new app with <= 31 API level.

SO if your app is not updated to latest <= 31 API level, start process on it, which is also time consuming.

from cordova-plugin-geolocation.

mobiliseapplabllp avatar mobiliseapplabllp commented on May 27, 2024

well

can you share your code and also plugin version

from cordova-plugin-geolocation.

theaminea avatar theaminea commented on May 27, 2024

getOwnPosition

giving error at plugins.Locationprovider???

whether to use this plugin https://github.com/ToniKorin/cordova-plugin-location-provider.git

I can't use that plugin with ionic 5 when import it is error and use cordova.plugin still error too. need help.
thank befor

from cordova-plugin-geolocation.

prabusharan avatar prabusharan commented on May 27, 2024

getOwnPosition

giving error at plugins.Locationprovider???

whether to use this plugin https://github.com/ToniKorin/cordova-plugin-location-provider.git

I can't use that plugin with ionic 5 when import it is error and use cordova.plugin still error too. need help. thank befor

Same issue i am also facing by using this plugin in ionic 5

from cordova-plugin-geolocation.

atmanegara avatar atmanegara commented on May 27, 2024
  1. cordova-plugin-locationservices-fix

this solved too

from cordova-plugin-geolocation.

mobiliseapplabllp avatar mobiliseapplabllp commented on May 27, 2024

from cordova-plugin-geolocation.

atmanegara avatar atmanegara commented on May 27, 2024
  1. cordova-plugin-locationservices-fix

this simple, just only install this plugin https://github.com/ZenCity/cordova-plugin-locationservices , but im not using ionic

from cordova-plugin-geolocation.

secretmoo35 avatar secretmoo35 commented on May 27, 2024

i'm use this plugin https://github.com/Esri/cordova-plugin-advanced-geolocation.git work on ionic 5(android only)

1.ionic cordova plugin add https://github.com/Esri/cordova-plugin-advanced-geolocation.git

  1. declare AdvancedGeolocation declare var AdvancedGeolocation: any;
  public getCurrentPositionAndroid(): Promise<any> {

    return new Promise((resolve, reject) => {

        AdvancedGeolocation.start((success: any) => {
          try {
            var jsonObject = JSON.parse(success);
            console.log('Provider ' + JSON.stringify(jsonObject));
            switch (jsonObject.provider) {
              case 'gps':
                if (jsonObject.latitude != '0.0') {
                  resolve({ coords: { latitude: jsonObject.latitude, longitude: jsonObject.longitude } });
                }
                break;
              case 'network':
                if (jsonObject.latitude != '0.0') {
                  resolve({ coords: { latitude: jsonObject.latitude, longitude: jsonObject.longitude } });
                }
                break;
            }
          }
          catch (exc) {
            console.log('Invalid JSON: ' + exc);
          }
        },
          function (error) {
            reject({ latitude: null, longitude: null });
            console.log('ERROR! ' + JSON.stringify(error));
          },
          ////////////////////////////////////////////
          //
          // REQUIRED:
          // These are required Configuration options!
          // See API Reference for additional details.
          //
          ////////////////////////////////////////////
          {
            'minTime': 500,         // Min time interval between updates (ms)
            'minDistance': 1,       // Min distance between updates (meters)
            'noWarn': true,         // Native location provider warnings
            'providers': 'all',     // Return GPS, NETWORK and CELL locations
            'useCache': false,       // Return GPS and NETWORK cached locations
            'satelliteData': false, // Return of GPS satellite info
            'buffer': false,        // Buffer location data
            'bufferSize': 0,         // Max elements in buffer
            'signalStrength': false // Return cell signal strength data
          });
    });

  }

  stopGetCurrentPositionAndroid() {
      AdvancedGeolocation.stop();
  }
      var position:any;
      if (this.platform.is("android")) {
        console.log("android");
        position = await this.getCurrentPositionAndroid();
        this.stopGetCurrentPositionAndroid();
      } else {
        console.log("ios");
        try {
          position = await this.geolocation.getCurrentPosition({ maximumAge: 1000, enableHighAccuracy: false });
        } catch (error) {
          // TO DO
        }
      }

     console.log(position);

from cordova-plugin-geolocation.

breautek avatar breautek commented on May 27, 2024

The Android System Webview has had a new update published yesterday. We have reasonable suspicion that the issue was caused by a previous Android webview update.

Uninstalling Google Play services shouldn't be necessary, just ensure you have the latest Android System Webview package installed on your device.

If anybody can confirm that using the latest system webview solves the problem, then I think it helps prove that the issue indeed was in the android webview.

from cordova-plugin-geolocation.

sonikdesign avatar sonikdesign commented on May 27, 2024

Hi all,
I've the same issue with cordova-plugin-geolocation in some devices with Android 12. I've tried:
"cordova-plugin-locationservices": "^2.1.0"
it works (on an Android device without troubles with recent Webview updates, I've not tested APK in devices with troubles), but it's too slow on first execution. The app freezes visually, then resumes working properly.

I'm working with cordova in a Quasar V1 project. This is the code used with this locationservices plugin:

cordova.plugins.locationServices.geolocation.getCurrentPosition(onSuccess, onError, options)

I'm sorry not to confirm if the solution works or not, but with this app freeze issue I can't ask customers to test it.

from cordova-plugin-geolocation.

gohrms avatar gohrms commented on May 27, 2024

I am using IONIC application and using geolocation '@awesome-cordova-plugins/geolocation/ngx'. This was working fine but since last few days it stopped. I am trying now to use "cordova-plugin-locationservices" with cordova.plugins.locationServices.geolocation.getCurrentPosition(onSuccess, onError, options) but it is giving me "property locationServices does on exists on type CordovaPlugins". Kindly help.

from cordova-plugin-geolocation.

gohrms avatar gohrms commented on May 27, 2024
  1. cordova-plugin-locationservices-fix

this solved too

Are you using ionic. Can you please share your sample code and specially which Import module did you use for "cordova.plugins.locationServices"

from cordova-plugin-geolocation.

waptaxi avatar waptaxi commented on May 27, 2024

If anybody can confirm that using the latest system webview solves the problem, then I think it helps prove that the issue indeed was in the android webview.

Tried the latest webview 107, beta webview 108, dev webview 109 - none of them solves the problem

from cordova-plugin-geolocation.

gohrms avatar gohrms commented on May 27, 2024

I am using IONIC and change "cordova-plugin-geolocation" to @capacitor/geolocation it working

//import { Geolocation } from '@ionic-native/geolocation/ngx';
//import { LocationAccuracy } from '@ionic-native/location-accuracy/ngx';
import { Geolocation,PositionOptions } from '@capacitor/geolocation';
...
public options: PositionOptions = {
    timeout: 5000, 
    enableHighAccuracy: true, 
    maximumAge: 3000
  };
...

/*async getCurrentCoordinates() {
    this.geolocation.getCurrentPosition(this.options).then((resp) => {
      this.latitude = resp.coords.latitude;
      this.longitude = resp.coords.longitude;
      console.log('accuracy:',resp.coords.accuracy);
     }).catch((error) => {
       console.log('Error getting location', error);
     });
  }
*/
  async getCurrentCoordinates() {
    const position = await Geolocation.getCurrentPosition(this.options);
    console.log('accuracy:',position.coords.accuracy);
    this.latitude = position.coords.latitude;
    this.longitude = position.coords.longitude;
  }

You mean to say, to convert the ionic cordova project to ionic capacitor project ? I tried to add capacitor in my cordova project and it gives me error "SyntaxError: Unexpected token '('" in adb logcat.

from cordova-plugin-geolocation.

sonikdesign avatar sonikdesign commented on May 27, 2024

Has anyone figured out what changes need to be made to the native code to avoid isues with geolocation? These 6-7 year old plugins, in a cordova application, just gave me compile problems, so I wasn't even able to test them.
Thanks to all who are looking for a solution.

from cordova-plugin-geolocation.

Soundariya-Bingu avatar Soundariya-Bingu commented on May 27, 2024

I am using IONIC and change "cordova-plugin-geolocation" to @capacitor/geolocation it working

//import { Geolocation } from '@ionic-native/geolocation/ngx';
//import { LocationAccuracy } from '@ionic-native/location-accuracy/ngx';
import { Geolocation,PositionOptions } from '@capacitor/geolocation';
...
public options: PositionOptions = {
    timeout: 5000, 
    enableHighAccuracy: true, 
    maximumAge: 3000
  };
...

/*async getCurrentCoordinates() {
    this.geolocation.getCurrentPosition(this.options).then((resp) => {
      this.latitude = resp.coords.latitude;
      this.longitude = resp.coords.longitude;
      console.log('accuracy:',resp.coords.accuracy);
     }).catch((error) => {
       console.log('Error getting location', error);
     });
  }
*/
  async getCurrentCoordinates() {
    const position = await Geolocation.getCurrentPosition(this.options);
    console.log('accuracy:',position.coords.accuracy);
    this.latitude = position.coords.latitude;
    this.longitude = position.coords.longitude;
  }

I used these links to install:
https://www.npmjs.com/package/@capacitor/geolocation#getcurrentposition
https://capacitorjs.com/docs/apis/geolocation

But getting this error in the console tab on the browser, I am using IONIC 5 in my Mobile app
Here is the error screenshot:

Screenshot_2022-11-29_16-12-24

Please help somebody, I struck for 2 days I tried so many things but nothing is working as expected.

Advance thanks to all who are looking for a solution.

from cordova-plugin-geolocation.

mobiliseapplabllp avatar mobiliseapplabllp commented on May 27, 2024

google announce (Security and privacy) section
https://developer.android.com/about/versions/12/behavior-changes-all

for security reason google can't access [ACCESS_FINE_LOCATION] on some Android 12 Mobile. it access only ACCESS_COARSE_LOCATION.
but i remove ACCESS_FINE_LOCATION from my project. i access only ACCESS_COARSE_LOCATION but problem not solve

from cordova-plugin-geolocation.

sonikdesign avatar sonikdesign commented on May 27, 2024

https://developer.android.com/about/versions/12/behavior-changes-all

We have problems after Android updates on devices with Android 8.1.0, 11 and 12.

With cordova-plugin-geolocation I have a timeout error (after 60 secs) in these devices.

from cordova-plugin-geolocation.

newtonstudio avatar newtonstudio commented on May 27, 2024

Hi Guys, I'm also suffering from this issue since few weeks ago.
After doing some research, i try to combine several methods by solving this issue. In summary:

  1. Go to google play and update user mobile to latest android web view version.
  2. Install LocationProvider cordova plugin (use ts-ignore to prevent ionic build error)
  3. enable timeout option on geolocation, and try use LocationProvider if geolocation has failed.

It works for me. Hope it helps.

My Environment is Angular+Ionic 4 with Cordova.

I tried to install two of this plugin:
cordova-plugin-geolocation 4.1.0 "Geolocation"
cordova-plugin-location-provider 1.5.4 "LocationProvider"

in my ts file:

import { Geolocation, GeolocationOptions } from '@ionic-native/geolocation';
import { Platform } from '@ionic/angular';
//dependency injection
constructor(private geolocation: Geolocation, private platform: Platform){}

somefunction(){
  this.geolocation.getCurrentPosition({ maximumAge: 3000, timeout: 5000, enableHighAccuracy: false }).then((resp) => {
    //do something
  }).catch((error) => {
        
        //can use platform to do platfom specific code here
	//@ts-ignore
	cordova.plugins.LocationProvider.getOwnPosition({ maximumAge: 3000, timeout: 5000, enableHighAccuracy: false },(resp)=>{
         //do something
        }, (error)=>{
        //do something
        });
}

from cordova-plugin-geolocation.

mobiliseapplabllp avatar mobiliseapplabllp commented on May 27, 2024

from cordova-plugin-geolocation.

sonikdesign avatar sonikdesign commented on May 27, 2024

Can anyone tell me where to report this issue with the latest Android updates? Because these updates are creating quite a few problems, several important frameworks are involved and so many days have gone by without finding a solution.

from cordova-plugin-geolocation.

sonikdesign avatar sonikdesign commented on May 27, 2024

Can anyone tell me where to report this issue with the latest Android updates? Because these updates are creating quite a few problems, several important frameworks are involved and so many days have gone by without finding a solution.

I answer to myself: https://issuetracker.google.com/

from cordova-plugin-geolocation.

breautek avatar breautek commented on May 27, 2024

I'm closing this issue because it doesn't appear to be related to Cordova.

To recap, Cordova doesn't implement any actual geolocation features for the Android platform. What the Cordova plugin does do is handle geolocation permissions for the application, hooking into the Webview's geolocation implementation. So in otherwords, the geolocation feature is provided by the system webview itself. Because this issue does not appear to be a permissions related issue, there isn't anything Cordova can do to resolve this problem.

Out of all the comments, the devices that is affected (Vivo, Oppo, Xioami, etc...). These devices often don't use standard AOSP software. I don't have access to any of these devices for testing, but the standard AOSP system webview appears to work as expected. And I know that some of these devices do not use, or uses a fork of the standard AOSP webview. Vivo for example has their own VivoBrowser that appears to be used based on the user agent. Unfortunately I do not have an answer of why this is happening on these specific devices, I just know that it's not something Cordova can correct. It's very likely an issue within their system webview implementation.

As for potential workarounds, several developers have posted success utilizing an alternate geolocation plugin that uses the native APIs instead of the browser-based APIs that this Cordova plugin relies on. So that may be a path to consider. Cordova will not implement a native-based implementation as a workaround as there are many community plugins that does this already.

from cordova-plugin-geolocation.

gohrms avatar gohrms commented on May 27, 2024

I had the same issue on my Vivo x70, today there was some auto update on play services and then I did restart the phone and now the same App has started working with GPS location being captured properly. I am not sure exactly was auto updated today on my phone. Can anyone try to update the "Play Services" and then retry.

As need to give solutions to the users who are facing the same issue.

It will be helpful if the issue is kept open to get more ideas and solution from people.

from cordova-plugin-geolocation.

sonikdesign avatar sonikdesign commented on May 27, 2024

Issue will be resolve, follow these instructions.

  1. Use this plugin which is free available on GitHub or npm.
    cordova-plugin-locationservices-fix
  2. In code use LocationServices instead of navigator.geolocation
    i.e. LocationServices.getCurrentPosition(,,)

how do you import it into your project? I found LocationServices.getCurrentPosition in:
cordova.plugins.locationServices.geolocation.getCurrentPosition(onSuccess, onError, options)
but my app freeze the first time this method is called.

from cordova-plugin-geolocation.

ravi106 avatar ravi106 commented on May 27, 2024

After Adding this plugin - cordova-plugin-locationservices-fix.Try this.
let trackGps;
public captureCurrentLocation() {
if (trackGps) {
(window as any).LocationServices.clearWatch(this.trackGps);
}
const options = { // options for capturing the geolocation
enableHighAccuracy: true,
timeout: 10000,
maximumAge: 0,
};
const success = (position: any) => {
console.log('Your current position is:');
console.log(Latitude & Longitude : ${position});
}
const error = (err: any) => {
console.log(ERROR(${err.code}): ${err.message});
}
trackGps = (window as any).LocationServices.watchPosition(success, error, options);
}

from cordova-plugin-geolocation.

009topersky avatar 009topersky commented on May 27, 2024

Good day everyone!
our team are using ionic 4 in our application,
To solve the issue we use the https://github.com/mapsplugin/cordova-plugin-googlemaps.

First, you have to follow the instruction on the documentation and get the API KEY from Google.
setup your project here: https://console.cloud.google.com/apis/credentials?authuser=2

Second, in config.xml add this line or you can read it on the documentation of the plugin:

<preference name="GOOGLE_MAPS_ANDROID_API_KEY" value="YOUR_API_KEY_FROM_GOOGLE_CONSOLE" />

Third, under app.module.ts include the LocationService

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [
           ....
           LocationService
           ....
           ]
});

Fourth, import the LocationService and create a function to get the geolocaion.

import {
  LocationService,
  MyLocation,
  MyLocationOptions
} from '@ionic-native/google-maps';

....

async getGoogleCurrentLocationAsync() {
    const options: MyLocationOptions = { enableHighAccuracy: true };
    
    return await LocationService.getMyLocation().then((myLocation) => {
      if (myLocation) {
        const coordinate: Coordinates = {
          latitude: myLocation.latLng.lat,
          longitude: myLocation.latLng.lng,
          accuracy: myLocation.accuracy,
          altitude: myLocation.altitude,
          speed: myLocation.speed,
          altitudeAccuracy: null,
          heading: null,
        }; 
  
        return coordinate;
      }
      return false;
    },
    (_error) => false)
    .catch((_e) => false)
  }

That's it!
I hope this answer will help!

Thanks

from cordova-plugin-geolocation.

mobiliseapplabllp avatar mobiliseapplabllp commented on May 27, 2024

Good day everyone! our team are using ionic 4 in our application, To solve the issue we use the https://github.com/mapsplugin/cordova-plugin-googlemaps.

First, you have to follow the instruction on the documentation and get the API KEY from Google. setup your project here: https://console.cloud.google.com/apis/credentials?authuser=2

Second, in config.xml add this line or you can read it on the documentation of the plugin:

<preference name="GOOGLE_MAPS_ANDROID_API_KEY" value="YOUR_API_KEY_FROM_GOOGLE_CONSOLE" />

Third, under app.module.ts include the LocationService

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [
           ....
           LocationService
           ....
           ]
});

Fourth, import the LocationService and create a function to get the geolocaion.

import {
  LocationService,
  MyLocation,
  MyLocationOptions
} from '@ionic-native/google-maps';

....

async getGoogleCurrentLocationAsync() {
    const options: MyLocationOptions = { enableHighAccuracy: true };
    
    return await LocationService.getMyLocation().then((myLocation) => {
      if (myLocation) {
        const coordinate: Coordinates = {
          latitude: myLocation.latLng.lat,
          longitude: myLocation.latLng.lng,
          accuracy: myLocation.accuracy,
          altitude: myLocation.altitude,
          speed: myLocation.speed,
          altitudeAccuracy: null,
          heading: null,
        }; 
  
        return coordinate;
      }
      return false;
    },
    (_error) => false)
    .catch((_e) => false)
  }

That's it! I hope this answer will help!

Thanks

Thanks for your answer

How many mobiles have you tested this code on?

from cordova-plugin-geolocation.

sonikdesign avatar sonikdesign commented on May 27, 2024

There's an Android WebView update, but the issue persists with Oppo's and Vivo's devices

from cordova-plugin-geolocation.

009topersky avatar 009topersky commented on May 27, 2024

Good day everyone! our team are using ionic 4 in our application, To solve the issue we use the https://github.com/mapsplugin/cordova-plugin-googlemaps.
First, you have to follow the instruction on the documentation and get the API KEY from Google. setup your project here: https://console.cloud.google.com/apis/credentials?authuser=2
Second, in config.xml add this line or you can read it on the documentation of the plugin:
<preference name="GOOGLE_MAPS_ANDROID_API_KEY" value="YOUR_API_KEY_FROM_GOOGLE_CONSOLE" />
Third, under app.module.ts include the LocationService

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [
           ....
           LocationService
           ....
           ]
});

Fourth, import the LocationService and create a function to get the geolocaion.

import {
  LocationService,
  MyLocation,
  MyLocationOptions
} from '@ionic-native/google-maps';

....

async getGoogleCurrentLocationAsync() {
    const options: MyLocationOptions = { enableHighAccuracy: true };
    
    return await LocationService.getMyLocation().then((myLocation) => {
      if (myLocation) {
        const coordinate: Coordinates = {
          latitude: myLocation.latLng.lat,
          longitude: myLocation.latLng.lng,
          accuracy: myLocation.accuracy,
          altitude: myLocation.altitude,
          speed: myLocation.speed,
          altitudeAccuracy: null,
          heading: null,
        }; 
  
        return coordinate;
      }
      return false;
    },
    (_error) => false)
    .catch((_e) => false)
  }

That's it! I hope this answer will help!
Thanks

Thanks for your answer

How many mobiles have you tested this code on?

We are testing this solution in Vivo, Samsung, Xiaomi, Huawei and OnePlus devices and from different Android API versions (9,10,11 and 12)

from cordova-plugin-geolocation.

sonikdesign avatar sonikdesign commented on May 27, 2024

The December 2 update Android System WebView works on both Android 8.1 and 12. If the update doesn't work, you'll need to remove and install Android System WebView.

from cordova-plugin-geolocation.

mobiliseapplabllp avatar mobiliseapplabllp commented on May 27, 2024

https://github.com/mapsplugin/cordova-plugin-googlemaps.

hello
how to install "https://github.com/mapsplugin/cordova-plugin-googlemaps". this plugin. when we create apk its showing error please provide npm command

Thanks

from cordova-plugin-geolocation.

009topersky avatar 009topersky commented on May 27, 2024

https://github.com/mapsplugin/cordova-plugin-googlemaps.

hello how to install "https://github.com/mapsplugin/cordova-plugin-googlemaps". this plugin. when we create apk its showing error please provide npm command

Thanks

You can check the documentation here:
https://github.com/ionic-team/ionic-native-google-maps/blob/master/documents/README.md

Thanks

from cordova-plugin-geolocation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.