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

Android: Location permissions not auto-added when using Ti.Geolocation API as of 9.0.0

    Details

    • Story Points:
      5
    • Sprint:
      2020 Sprint 2

      Description

      This issue was caught before release.

      Summary:
      When doing a "device" or "production" build, Titanium's build system is supposed to auto-add the below permissions to the "AndroidManifest.xml" when the app uses the Ti.Geolocation APIs.

      • android.permission.ACCESS_COARSE_LOCATION
      • android.permission.ACCESS_FINE_LOCATION

      This has stopped working as of Titanium 9.0.0 (before release).

      Steps to reproduce:

      1. Set up a Classic app with the below code.
      2. Build and run on an Android device. (Not an emulator.)
      3. Notice app reports error: Failed to acquire location permission

      app.js

      function monitorLocation() {
      	function start() {
      		Ti.Geolocation.addEventListener("location", function(e) {
      			label.text = JSON.stringify(e, null, 4);
      			Ti.API.info("@@@ location received: " + JSON.stringify(e));
      		});
      	}
      	var hasPermission = Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE);
      	if (!hasPermission) {
      		Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE, function(e) {
      			Ti.API.info("@@@ permission result: " + JSON.stringify(e));
      			if (e.success) {
      				start();
      			} else {
      				label.text = "\nFailed to acquire location permission from end-user.";
      			}
      		});
      	} else {
      		start();
      	}
      }
      var window = Ti.UI.createWindow();
      var scrollView = Ti.UI.createScrollView({
      	layout: "vertical",
      	scrollType: "vertical",
      	width: Ti.UI.FILL,
      	height: Ti.UI.FILL,
      });
      var label = Ti.UI.createLabel({
      	text: "\nWaiting for GPS data...",
      	top: (Ti.App.iOS ? "25dp" : "5dp"),
      	height: Ti.UI.SIZE,
      	left: "5dp",
      	right: "5dp",
      	bottom: "5dp",
      });
      scrollView.add(label);
      window.add(scrollView);
      window.addEventListener("open", function(e) {
      	monitorLocation();
      });
      window.open();
      

        Attachments

          Activity

            People

            • Assignee:
              jquick Joshua Quick
              Reporter:
              jquick Joshua Quick
              Reviewer:
              Gary Mathews
              Tester:
              Satyam Sekhri
            • 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 Integration