Skip to content

[@capacitor/geolocation] Missing Error Codes in Exceptions #2428

@louis123562

Description

@louis123562

Bug Report

Plugin(s)

Geolocation Capacitor Plugin

Capacitor Version

💊   Capacitor Doctor  💊

Latest Dependencies:

  @capacitor/cli: 7.4.4
  @capacitor/core: 7.4.4
  @capacitor/android: 7.4.4
  @capacitor/ios: 7.4.4

Installed Dependencies:

  @capacitor/cli: 7.4.4
  @capacitor/android: 7.4.4
  @capacitor/core: 7.4.4
  @capacitor/ios: 7.4.4

[success] iOS looking great! 👌
[success] Android looking great! 👌

Platform(s)

Android

Current Behavior

We are engaging multiple issues when trying to get the location on the following devices:

  • Xiaomi Redmi Note 11 Pro+ 5G
  • Xiaomi Redmi 12C
  • Samsung A226B/DSN Galaxy A22 5G
  • Samsung A336B/DSN Galaxy A33 5G
  • Samsung A346B Galaxy A34 5G

We are missing the error codes described in the docs, as shown here:

Image

The only message we get is:

Could not obtain location in time. Try with a higher timeout.

Expected Behavior

Get an error code to get more information out of it, why the location could not be obtained.

Code Reproduction

  /**
   * Get current location of the device
   * @returns Current location of the device
   */
  public async getCurrentLocation(): Promise<Position | null> {

    const options: PositionOptions = {
      enableHighAccuracy: true,
      maximumAge: 0,
    };

    let position: Position = null;

    try {
      position = await Geolocation.getCurrentPosition(options);
    } catch (error) {
      console.log(error);
    }

    return position;
  }

Other Technical Details

package.json:

 "dependencies": {
    "@angular-devkit/architect": "^0.1900.6",
    "@angular/cdk": "^19.0.4",
    "@angular/common": "^19.0.5",
    "@angular/core": "^19.0.5",
    "@angular/forms": "^19.0.5",
    "@angular/platform-browser": "^19.0.5",
    "@angular/platform-browser-dynamic": "^19.0.5",
    "@angular/router": "^19.0.5",
    "@aparajita/capacitor-biometric-auth": "^9.0.0",
    "@capacitor-community/file-opener": "^7.0.1",
    "@capacitor-community/generic-oauth2": "^7.0.0",
    "@capacitor-community/privacy-screen": "^6.0.0",
    "@capacitor-community/sqlite": "7.0.1",
    "@capacitor/android": "^7.4.3",
    "@capacitor/app": "^7.0.2",
    "@capacitor/background-runner": "2.2.0",
    "@capacitor/barcode-scanner": "^2.0.4",
    "@capacitor/browser": "^7.0.2",
    "@capacitor/camera": "^7.0.2",
    "@capacitor/clipboard": "^7.0.2",
    "@capacitor/core": "^7.4.3",
    "@capacitor/device": "^7.0.2",
    "@capacitor/filesystem": "^7.1.4",
    "@capacitor/geolocation": "^7.1.5",
    "@capacitor/haptics": "^7.0.2",
    "@capacitor/ios": "^7.4.3",
    "@capacitor/keyboard": "^7.0.2",
    "@capacitor/network": "^7.0.2",
    "@capacitor/preferences": "^7.0.2",
    "@capacitor/share": "^7.0.2",
    "@capacitor/splash-screen": "^7.0.2",
    "@capacitor/status-bar": "^7.0.2",
    "@capawesome/capacitor-android-edge-to-edge-support": "^7.2.3",
    "@capawesome/capacitor-app-review": "^7.0.1",
    "@capgo/capacitor-navigation-bar": "^7.1.26",
    "@capgo/capacitor-updater": "^7.9.1",
    "@fortawesome/angular-fontawesome": "^1.0.0",
    "@fortawesome/fontawesome-svg-core": "^6.7.2",
    "@fortawesome/free-brands-svg-icons": "^6.7.2",
    "@fortawesome/pro-duotone-svg-icons": "^6.7.2",
    "@fortawesome/pro-light-svg-icons": "^6.7.2",
    "@fortawesome/pro-regular-svg-icons": "^6.7.2",
    "@fortawesome/pro-solid-svg-icons": "^6.7.2",
    "@ionic/angular-toolkit": "^12.2.0",
    "@ionic/storage-angular": "^4.0.0",
    "@microsoft/signalr": "^8.0.0",
    "@ngx-translate/core": "^16.0.4",
    "@planzeit-gmbh/angular": "8.6.5",
    "@planzeit-gmbh/core": "8.6.5",
    "@sentry/angular": "9.46.0",
    "@sentry/capacitor": "2.3.1",
    "@sentry/cli": "2.54.0",
    "@types/luxon": "^3.4.1",
    "@types/onesignal-cordova-plugin": "^2.6.5",
    "capacitor-native-settings": "^7.0.2",
    "chart.js": "^4.4.3",
    "jeep-sqlite": "^2.8.0",
    "lottie-web": "^5.12.2",
    "luxon": "^3.4.4",
    "ng2-charts": "^8.0.0",
    "ngx-lottie": "^12.0.0",
    "ngx-translate-multi-http-loader": "^19.0.1",
    "onesignal-cordova-plugin": "^5.1.0",
    "rxjs": "^7.8.1",
    "sql.js": "1.11.0",
    "swiper": "^11.0.4",
    "tslib": "^2.3.1",
    "zone.js": "~0.15.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~19.0.6",
    "@angular-eslint/builder": "^19.0.2",
    "@angular-eslint/eslint-plugin": "^19.0.2",
    "@angular-eslint/eslint-plugin-template": "^19.0.2",
    "@angular-eslint/template-parser": "^19.0.2",
    "@angular/cli": "~19.0.6",
    "@angular/compiler": "^19.0.5",
    "@angular/compiler-cli": "^19.0.5",
    "@angular/language-service": "~19.0.5",
    "@capacitor/assets": "^3.0.5",
    "@capacitor/cli": "^7.4.3",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^22.18.0",
    "@typescript-eslint/eslint-plugin": "^8.19.1",
    "@typescript-eslint/parser": "^8.19.1",
    "copyfiles": "^2.4.1",
    "cordova-plugin-lottie-splashscreen": "^0.10.0",
    "dotenv": "^17.2.3",
    "eslint": "^8.57.1",
    "eslint-plugin-import": "^2.31.0",
    "eslint-plugin-jsdoc": "^50.6.1",
    "eslint-plugin-prefer-arrow": "^1.2.3",
    "jasmine-core": "~3.8.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "^6.3.9",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "ts-node": "^10.9.2",
    "typescript": "5.5",
    "wrangler": "^3.109.1"
  },
  "cordova": {
    "plugins": {
      "cordova-plugin-lottie-splashscreen": {}
    }
  },
  "browser": {
    "crypto": false
  },
  "browserslist": [
    "Chrome >=61",
    "ChromeAndroid >=61",
    "Firefox >=63",
    "Firefox ESR",
    "Edge >=79",
    "Safari >=13",
    "iOS >=13"
  ]

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions