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

iOS: Ti.Geolocation.hasGeolocationPermission() and Ti.Geolocation.getCurrentPosition() are not working on IOS 7

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: Release 5.1.1
    • Fix Version/s: Release 5.2.0
    • Component/s: iOS
    • Labels:
    • Environment:

      Xcode 7.2
      iOS 7
      SDK 5.1.1GA

    • Story Points:
      3
    • Sprint:
      2016 Sprint 3 SDK

      Description

      Issue Description

      Geolocation popup permission is not triggered by Ti.Geolocation.hasGeolocatinPermission()
      Ti.Geolocation.hasGeolocatinPermission() does not work on iOS 7. It returns true before permission has been determined. Once it is determined it does not return the right value.
      Ti.Geolocation.requestLocationPermissions() never calls the callback on iOS 7.

      TestCase
      1. Create a new Alloy default Application
      2. Open views/index.xml
      3. Replace the inside with the next code:

        <Alloy>
        	<Window class="container" id="win">
        		<View>
        			<View class="container2">
        				<Button class="btn" title="Check Permission" onClick="checkPermission" />
        				<Button class="btn" title="Request Permission" onClick="requestPermission" />
        				<Button class="btn" title="Check & Request Permission" onClick="checkRequestPermission" />
        				<Button class="btn" title="Get Current Position" onClick="getCurrentPosition" />
        			</View>
        		</View>
        	</Window>
        </Alloy>
        

      4. Open controllers/index.js
      5. Replace the inside with the next code:

        $.win.open();
         
        function checkPermission(){
        	if(Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE)){
        		Ti.API.info("APP HAS PERMISSION");	
        	}else{
        		Ti.API.info("APP DOES NOT HAVE PERMISSION");
        		requestPermission();
        	}
        }
         
        function requestPermission(){
        	Ti.API.info("REQUESTING PERMISSION");
        	Ti.Geolocation.requestLocationPermissions(Titanium.Geolocation.AUTHORIZATION_WHEN_IN_USE,function(e){
        		Ti.API.info("INSIDE CALLBACK");
        		if(e.success){
        			Ti.API.info("PERMISSION GRANTED");
        		}else{
        			Ti.API.info("PERMISSION DENIED");
        		}
        	});
        }
         
        function checkRequestPermission(){
        	checkPermission(requestPermission);
        }
         
        function getCurrentPosition(successHandler,errorHandler){
        	Ti.Geolocation.getCurrentPosition(function(result){
        		if (result.error) {
        			Ti.API.info("GetCurrentPosition Error");
        		}else{
        			Ti.API.info("GetCurrentPosition returned" + JSON.stringify(result));
        		}
        	});
        }
        

        #open the tiapp.xml file and add the next lines inside ios/plist/dict

                        <key>NSLocationWhenInUseUsageDescription</key>
                        <string>Testing Location in use </string>
        

      6. Run
      Steps to Reproduce
      1. Press "Check Location Permission" button which calls Ti.Geolocation.hasLocationPermissions(). It should return true and you should see "APP HAS PERMISSION" output.
      2. Press "Request Geolocation Permission" which calls Ti.Geolocation.requestLocationPermissions() You should see "REQUESTING PERMISSION" in your output.
      3. Third button calls Ti.Geolocation.getCurrentPosition() to get users current position which is what triggers geolocation permission popup to show. If you grant permission in the popup then press "Check Location Permission" button again and you should see "APP DOES NOT HAVE PERMISSION" followed by "REQUESTING PERMISSION". This also happens if you refuse permission.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ssombhatla Srikanth Sombhatla (Inactive)
                Reporter:
                rramirez Ricardo Ramirez
                Reviewer:
                Hans Knöchel
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-20839
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code