Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-12201

Possibility to check if Geolocation Permissions have been granted before

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      As soon as e.g. getCurrentLocation() is called, the OS asks for geolocation permission. This is great.
      But sometimes you want to see if the user has granted these permissions, without possibly trigger the native permission popup.

      there is the `navigator.permissions` api, but not available for iOS.

      POSSIBLE USE CASES:

      • You have a button "enable geolocation" in your app. Sure, you store somewhere, as soon as the user has granted the permissions once. But the permissions can be revoked, that the app doesn't know about and then would be out of sync.
      • The user starts the app and you want to track the users location, where the app has been opened. If you wouldn't have a check, the user will get asked right away for geolocation permissions, which is very bad UX.

      IMAGINABLE USAGE:

      navigator.geolocation.hasPermission(result => {
      if (result.isGranted)

      { // proceed with e.g. navigator.geolocation.getCurrentPosition() without triggering the native permission popup }

      });

      or there might be even an easy workaround that doesn't require any alteration - but would be great to have this out of the box.

        Attachments

          Activity

            People

            • Assignee:
              jcesarmobile jcesarmobile
              Reporter:
              zwacky Simon
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: