Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27976] iOS 14: Expose API to use Core Location AccuracyAuthorization

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2020-09-16T19:34:40.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.2.0
ComponentsiOS
Labelsgeolocation
ReporterVijay Singh
AssigneeVijay Singh
Created2020-06-23T18:36:24.000+0000
Updated2020-09-16T19:34:40.000+0000

Description

Apple has exposed new APIs CoreLocation framework e.g. https://developer.apple.com/documentation/corelocation/claccuracyauthorization?changes=latest_major https://developer.apple.com/documentation/corelocation/cllocationmanager/3600217-requesttemporaryfullaccuracyauth?changes=latest_major https://developer.apple.com/documentation/corelocation/cllocationmanager/3600216-requesttemporaryfullaccuracyauth?changes=latest_major. Expose new APIs in SDK to use . New APIs- Constants -
Ti.Geolocation.ACCURACY_AUTHORIZATION_FULL 
Ti.Geolocation.ACCURACY_AUTHORIZATION_REDUCED
Property (read-only)-
Ti.Geolocation.locationAccuracyAuthorization
function -
Ti.Geolocation.requestTemporaryFullAccuracyAuthorization('purposekey1', callback);

Attachments

FileDateSize
iOS14-request-full-accurracy.png2020-09-09T20:57:33.000+0000476512
iOS14-request-permission.png2020-09-09T20:57:29.000+0000531339

Comments

  1. Vijay Singh 2020-07-10

    Test Case - Steps - 1. Create app. Add key 'purposekey1' in tiapp.xml. Follow doc to add key. 2. Run the app. On launch it should show prompt to ask location access permission with map. 3. If, on map there is precise 'on' (which means app has full accuracy authorization). Click it and make it off. 4. Give permission to location by clicking on appropriate option. 5. Click on button 'Log Constants'. It should log proper values. 6. Click on button 'Get accuracy authorization'. It should show alert 'accuracy authorization is reduced'. 7. Click on button 'Request full accuracy'. It should show prompt. On click of prompt it should show proper alert. 8. Try without adding key 'purposekey1' in tiapp.xml . On click of 'Request full accuracy' , it should show proper error. 9. Try with precise 'on' in step 3 (need to delete app first). On click of 'Request full accuracy' , it should show alert that 'App is already authorized for full accuracy'
       var win = Ti.UI.createWindow({
       	layout: 'vertical',
       	backgroundColor: 'white' 
       });
        
       var button1 = Ti.UI.createButton({
       	top: 100,
       	title: 'Log constants'
       });
        
       button1.addEventListener('click', function(e){
       	Ti.API.info('ACCURACY_AUTHORIZATION_FULL is ' 
       		+Ti.Geolocation.ACCURACY_AUTHORIZATION_FULL);
        
       	Ti.API.info('ACCURACY_AUTHORIZATION_REDUCED is ' 
       		+Ti.Geolocation.ACCURACY_AUTHORIZATION_REDUCED);
       });
        
       var button2 = Ti.UI.createButton({
       	top: 50,
       	title: 'Get accuracy authorization'
       });
        
       button2.addEventListener('click', function(e){
       	var accuracy = Ti.Geolocation.locationAccuracyAuthorization;
        
       	if (accuracy == Ti.Geolocation.ACCURACY_AUTHORIZATION_FULL) {
       		alert('accuracy authorization is full'); 
       	} else {
       		alert('accuracy authorization is reduced'); 
       	}
       });
        
       var button3 = Ti.UI.createButton({
       	top: 50,
       	title: 'Request full accuracy'
       });
        
       button3.addEventListener('click', function(e){
       	var accuracy = Ti.Geolocation.locationAccuracyAuthorization;
        
       	if (accuracy != Ti.Geolocation.ACCURACY_AUTHORIZATION_FULL) {
       		Ti.Geolocation.requestTemporaryFullAccuracyAuthorization('purposekey1', function(e){
       			if (e.success) {
       				if (e.accuracyAuthorization == Ti.Geolocation.ACCURACY_AUTHORIZATION_FULL) {
       					alert('App granted full accuracy authorization');
       				} else {
       					alert('App denied  full accuracy authorization');	
       				}
       			} else {
       				Ti.API.info('Error in  authorization is ', e.error);
       				alert('accuracy authorization failed. See log.');
       			}
       		});
       	} else {
       		alert('App is already authorized for full accuracy');
       	}
       });
        
       win.add(button1);
       win.add(button2);
       win.add(button3);
        
        
       Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_HIGH;
        
       function getLocation() {
           Ti.Geolocation.addEventListener('location', function(e) {
               Ti.API.info(JSON.stringify(e, null, 2));
           });
       }
        
       win.addEventListener('open', function() {
           if (Ti.Geolocation.hasLocationPermissions()) {
           		getLocation();
             } else {
               Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) {
                   if (e.success) {
       		        getLocation();
       		    } else {
                       alert('could not obtain location permissions');
                   }
               });
           }
       });
        
       win.open();
       
  2. Vijay Singh 2020-07-10

    PR - https://github.com/appcelerator/titanium_mobile/pull/11813
  3. Satyam Sekhri 2020-09-02

    FR Passed Waiting for Jenkins build
  4. Satyam Sekhri 2020-09-16

    Verified on: Mac OS: 10.15.4 SDK: 9.2.0.v20200915123928, 9.3.0.v20200915132757 Appc CLI: 8.1.1 JDK: 11.0.4 Node: 10.17.0 Studio: 6.0.0.202005141803 Xcode: 12.0 GM iPhone 7Plus(v14.0 GM)

JSON Source