question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Geolocation Throws An Error If Device Location Services Disabled

See original GitHub issue

Bug Report

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

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

Installed Dependencies:

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

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

The latest @capacitor/geolocation is installed, 1.3.1

Platform(s)

  • iOS
  • I am unable to confirm or deny if it occurs on Android

Current Behavior

  • If the device has ‘Location Services’ disabled within Settings
  • And you request requestPermissions() and/or checkPermissions()
  • It will throw an error

Expected Behavior

  • I would expect it to return a PermissionStatus of ‘denied’
  • I would not expect it to throw an error and have to handle it differently.
  • Error message returned is {message: “Location services are not enabled”, errorMessage: “Location services are not enabled”}

Code Reproduction

  • Call either methods below while running on a real world iOS device
  • It occurs regardless of destructuring the assignment or not
  • const { location } = await Geolocation.checkPermissions();
  • const { location } = await Geolocation.requestPermissions({ permissions: [‘location’] }); OR
  • await Geolocation.checkPermissions();
  • await Geolocation.requestPermissions();

Other Technical Details

npm --version output: 6.14.16

node --version output: v14.19.0

pod --version output (iOS issues only): 1.11.2

Additional Context

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
meernscommented, May 15, 2022

I have to open the location setting manually and show it to the user to enable it, it won’t show the GPS popup

catch (error) { if (error.message === 'location disabled') { return NativeSettings.open({ optionAndroid: AndroidSettings.Location, optionIOS: IOSSettings.LocationServices, }); } }

0reactions
ionitron-bot[bot]commented, Nov 10, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Geolocation Errors - Texas State Law Library
Go to Settings > Location on your phone and make sure one or both of these options is on. If they were enabled...
Read more >
Error Messages | Maps JavaScript API - Google Developers
This behavior typically indicates issues with either an API key or billing. In order to use Google Maps Platform products, billing must be...
Read more >
cordova-plugin-geolocation
This plugin provides information about the device's location, such as latitude and longitude. Common sources of location information include Global Positioning ...
Read more >
My tracker is reporting inaccurate GPS positions - what can I do?
In this article, we explain all reasons why you might see inaccurate location data from time to time in the Tractive GPS app,...
Read more >
Use Location Services for Alexa Skills - Amazon Developer
To determine whether the customer's device can share location, check whether the context.System.device.supportedInterfaces object has a Geolocation field. If ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found