Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1248] iOS 8 Location Services Incompatibility

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionNot Our Bug
Resolution Date2014-09-24T22:50:27.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
LabelsApp, Geolocation, Location, LocationServices, Services, Settings, SettingsApp, Studio, TCSupportTriage, Ti.Geolocation, Titanium, TitaniumStudio3.4, iOS8
ReporterJune Rockwell
AssigneeMauro Parra-Miranda
Created2014-09-24T00:35:36.000+0000
Updated2016-03-08T07:37:38.000+0000

Description

Using Titanium Studio 3.3.x, Ti.Geolocation worked flawlessly for iPhone 5S running iOS 7. But just today, I upgraded this iPhone 5S to iOS 8 and Ti.Geolocation can't getCurrentLocation. I turned on the Location Services in the iOS 8 Settings app but it doesn't save the setting configuration for my specific app. I would indicate "Always" for Location Services and switch back to my app. By the time I get to my app, the Location Services turns off automatically and I haven't even really pressed or swiped or did anything. And when I go back to the Settings app to check the location setting for my my app, the setting configuration wasn't saved at all and neither "Never" or "Always" were checked. This is this same with Titanium Studio 3.4.x

Attachments

FileDateSize
Before_saving.jpg2014-09-24T00:35:36.000+000012799
didnt_save.jpg2014-09-24T00:35:36.000+000010660

Comments

  1. Amimul Hossain 2014-09-24

    Hello, [~jhrockwell] According to the Titanium Location service Documentation [iOS Development Considerations](http://docs.appcelerator.com/titanium/latest/#!/guide/Tracking_Position_and_Heading-section-29004915_TrackingPositionandHeading-iOSDevelopmentConsiderations) Starting with iOS 8, to use location services, you need to add either the NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription key to the iOS plist section of the project's tiapp.xml file.

    CODE SEGMENT

       <ti:app>
           <ios>
               <plist>
                   <dict>
                       <key>NSLocationAlwaysUsageDescription</key>
                       <string>
                           Specify the reason for accessing the user’s location information.
                           This appears in the alert dialog when asking the user for permission to
                           access their location.
                       </string>
                   </dict>
               </plist>
           </ios>
       </ti:app>
       
    I have tested the Titanium location service API in iOS 8.0 Device, with the above code section in tiapp.xml file. it's working fine. Once the location service is enabled in an app, it remains enabled. Thanks.
  2. June Rockwell 2014-09-24

    @Amimul Hossain thanks. The settings configuration in the Settings app now save. But when the user first installs the app, do they have to go to the iOS Settings App to save the configuration or by adding NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription the settings should be automatically saved in the Settings App without the user having to set the configurations? Right now, after trying it, I have to go the Settings App and set the configuration. Is this ideal?
  3. Jon Alter 2014-09-24

    Hi [~jhrockwell], I have put together a little sample to test your issue. Please follow the instructions below.

    Create a new app

    Paste the example code below into your app.js

    Add the code segment posted by [~ahossain] into your tiapp.xml

    Run the app

    When the app launches, click the 'getCurrentPostion' button

    You should see an alert dialog asking if you would like to allow the app access to your location... click 'Allow'.

    You should now see a JSON string of your current position in the middle of the screen.

    You can also test what will happen when you click 'Don't Allow' by deleting your app from your device and reinstalling the app. After doing this it will prompt you to allow again.

    Keep an eye on your device log while testing this to see if there are any helpful log messages. Let me know how it goes.
       var win = Ti.UI.createWindow({backgroundColor:'#FFF'});
       win.open();
       
       var button = Ti.UI.createButton({
       	title:'getCurrentPosition',
       	top: 10, height: 50,
       	left: 10, right: 10
       });
       win.add(button);
       button.addEventListener('click', function() {
       	Ti.Geolocation.getCurrentPosition(function(e) {
       		var loc = JSON.stringify(e);
       		label.text = loc;
       		Ti.API.info('getCurrentPosition: ' + loc);
       	});
       });
       
       var label = Ti.UI.createLabel({
       	top: 70,
       	bottom: 10,
       	left: 10,
       	right: 10,
       	text: 'log'
       });
       win.add(label);
       
  4. June Rockwell 2014-09-24

    @Jon Alter, thanks! I forgot to update some things on the SDK. Your instructions helped a lot in me figuring out what I've missed.
  5. Mauro Parra-Miranda 2014-09-24

    [~jhrockwell]: Based on your last comment. Does this work for you now? Do you agree to close this issue?
  6. June Rockwell 2014-09-24

    Yes, it works now. The issue is resolved. Thank you all for your help!

JSON Source