Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-23655

Windows: Implement Ti.Geolocation.requestLocationPermissions/hasLocationPermissions methods to match iOS and Android behaviour

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 5.4.0
    • Fix Version/s: Release 6.0.0
    • Component/s: Windows
    • Labels:
    • Environment:

      Windows 10 Pro
      Appc CLI Core: 5.4.0-33
      Appc CLI NPM: 4.2.7
      Ti SDK: 5.3.0.GA,
      Appc Studio: 4.7.0.201607130543

    • Story Points:
      5
    • Sprint:
      2016 Sprint 15 SDK

      Description

      Description

      As part of TIMOB-19479 the Gelocation permissions was rewritten to be consistent across iOS and Android and use Ti.Geolocation.hasPermissions. Windows currently uses a different way to request permissions that can be seen in TIMOB-23389, however it should move to match iOS and Android. A code sample can be found below and a real world example found in Geocoder

      Ti.Geolocation.preferredProvider = "gps";
          function locationCallback(e) {
              if (!e.success || e.error) {
                  alert("error:" + JSON.stringify(e.error));
                  return;
              }
              Ti.API.info(JSON.stringify(e));
              var longitude = e.coords.longitude;
              var latitude = e.coords.latitude;
          };
          if (Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS)) {
              alert("Access already granted!");
              Titanium.Geolocation.addEventListener("location", locationCallback);
          } else {
                      Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) {
                if (e.success === true) {
                                  alert("Access now granted!");
                    Titanium.Geolocation.addEventListener("location", locationCallback);
                } else {
                    console.log("Access denied, error: " + e.error);
                }
            });
          }
      

      Additionally to this Ti.Geolocation.hasLocationPermissions should also be implemented to allow a user to check if permissions have already been granted

      Steps to reproduce
      1. Run the code above on Windows Platform {{appc run -p windows }}
      Actual result

      You should be prompted to allow location

      Expected result

      The app will throw an error as the methods are not implemented

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kiguchi Kota Iguchi
                Reporter:
                eharris Ewan Harris
                Reviewer:
                Gary Mathews
              • Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Source Code