Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17638] iOS8: Support New Geo Permissions

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-09-15T17:35:20.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.4.0, Release 3.5.0
ComponentsiOS
Labelsios8
ReporterBen Bahrenburg
AssigneeChee Kiat Ng
Created2014-09-07T22:38:37.000+0000
Updated2014-11-21T20:30:08.000+0000

Description

Apple has changed how Location Services Permissions are handled in iOS8. Because of this if iOS8 is the deployment target the Ti SDK Geo functions will stop working. Approach on now to fix : https://gist.github.com/benbahrenburg/c4c992c8c61d197510ea PR : https://github.com/appcelerator/titanium_mobile/pull/6028

Comments

  1. Ben Bahrenburg 2014-09-08

    How to test: ___________________ Testing Geo AlwaysUsage: ++++++++++++++++++++++++ 1. Using an Ti SDK with this patch applied create a test app ( in classic mode ) 2. Update the app.js with this sampel https://gist.github.com/benbahrenburg/c4c992c8c61d197510ea#how-to-test-this 4. Open the tiapp.xml in the ios / plist / dict section add the below:
       <key>NSLocationAlwaysUsageDescription</key>
       <string>Test NSLocationAlwaysUsageDescription</string>
       
    5. Compile and push to your device or the simulator. Please note you must target iOS8. 6. Press the btnAuthorization button, you should see a message that says Ti.Geolocation.AUTHORIZATION_UNKNOWN 7. Press the btnGeoTest button, you should now see the permission box with the message Test NSLocationAlwaysUsageDescription 8. Press the approve button 9. You should now see the event below fire
       Ti.Geolocation.addEventListener('authorization',function(e){
       	Ti.API.info('authorization event:' + JSON.stringify(e));
       });
       
    10. Press the btnAuthorization button, you should now see an alert with Ti.Geolocation.AUTHORIZATION_ALWAYS or Ti.Geolocation.AUTHORIZATION_AUTHORIZED Testing Geo In Usage Permission: ++++++++++++++++++++++++ 1. Next reset your simulator or uninstall the app from your device 2. Remove the NSLocationAlwaysUsageDescription settings from your tiapp.xml 3. Open the tiapp.xml in the ios / plist / dict section add the below:
       <key>NSLocationWhenInUseUsageDescription</key>
       <string>Test NSLocationWhenInUseUsageDescription</string>
       
    4. Compile and push to your device or the simulator. Please note you must target iOS8. 5. Press the btnAuthorization button, you should see a message that says Ti.Geolocation.AUTHORIZATION_UNKNOWN 6. Press the btnGeoTest button, you should now see the permission box with the message Test NSLocationWhenInUseUsageDescription 7. Press the approve button 8. You should now see the event below fire
       Ti.Geolocation.addEventListener('authorization',function(e){
       	Ti.API.info('authorization event:' + JSON.stringify(e));
       });
       
    9. Press the btnAuthorization button, you should now see an alert with Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE 10. Next reset your simulator or uninstall the app from your device Testing what happens if you have both NSLocationWhenInUseUsageDescription and NSLocationAlwaysUsageDescription ++++++++++++++++++++++++ 1. Next reset your simulator or uninstall the app from your device 2. Open the tiapp.xml in the ios / plist / dict section add the below:
       <key>NSLocationWhenInUseUsageDescription</key>
       <string>Test NSLocationWhenInUseUsageDescription</string>
       <key>NSLocationAlwaysUsageDescription</key>
       <string>Test NSLocationAlwaysUsageDescription</string>
       
    4. Compile and push to your device or the simulator. Please note you must target iOS8. 5. Press the btnAuthorization button, you should see a message that says Ti.Geolocation.AUTHORIZATION_UNKNOWN 6. Press the btnGeoTest button, you should now see the permission box with the message Test NSLocationAlwaysUsageDescription 7. Press the approve button 8. You should now see the event below fire
       Ti.Geolocation.addEventListener('authorization',function(e){
       	Ti.API.info('authorization event:' + JSON.stringify(e));
       });
       
    9. Press the btnAuthorization button, you should now see an alert with Ti.Geolocation.AUTHORIZATION_ALWAYS or Ti.Geolocation.AUTHORIZATION_AUTHORIZED 10. Next reset your simulator or uninstall the app from your device Testing iOS7 Support ++++++++++++++++++++++++ 1. Next reset your simulator or uninstall the app from your device 2. Open the tiapp.xml in the ios / plist / dict section add the below:
       <key>NSLocationWhenInUseUsageDescription</key>
       <string>Test NSLocationWhenInUseUsageDescription</string>
       <key>NSLocationAlwaysUsageDescription</key>
       <string>Test NSLocationAlwaysUsageDescription</string>
       
    4. Compile and push to your device or the simulator. Please note you must target iOS7. 5. Press the btnAuthorization button, you should see a message that says Ti.Geolocation.AUTHORIZATION_UNKNOWN 6. Press the btnGeoTest button, you should now see the permission box with the text provided as part of the purpose 7. Press the approve button 8. You should now see the event below fire
       Ti.Geolocation.addEventListener('authorization',function(e){
       	Ti.API.info('authorization event:' + JSON.stringify(e));
       });
       
    9. Press the btnAuthorization button, you should now see an alert with Ti.Geolocation.AUTHORIZATION_ALWAYS or Ti.Geolocation.AUTHORIZATION_AUTHORIZED
  2. Mark Mokryn 2014-09-10

    Any update on this? This is a showstopper.... Geolocation is now totally broken with iOS SDK 8, including on iOS 7 devices
  3. Ingo Muschenetz 2014-09-10

    It is in progress, but it would be helpful to know if the PR works for you as well. The plan is to have this as part of 3.4.0.
  4. Chee Kiat Ng 2014-09-11

    PR Reviewed, approved and merged.
  5. Jon Alter 2014-09-11

    master PR: https://github.com/appcelerator/titanium_mobile/pull/6055 Backport 3_4_X PR: https://github.com/appcelerator/titanium_mobile/pull/6059
  6. Ingo Muschenetz 2014-09-11

    [~cng] did you make the suggested changes on the PR before merging?
  7. Olga Romero 2014-09-13

    Tested the following code
       var win = Ti.UI.createWindow({backgroundColor:'white'});
       
       win.addEventListener('click', function() {
           var authCode = Ti.Geolocation.locationServicesAuthorization;
           if (authCode === Ti.Geolocation.AUTHORIZATION_ALWAYS) {
               console.log('AUTHORIZATION_ALWAYS');
           } else if (authCode === Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE) {
               console.log('AUTHORIZATION_WHEN_IN_USE');
           } else {
               console.log('NOT AUTHORIZED :(');
           }
       });
       
       Ti.Geolocation.addEventListener('authorization', function(e) {
           console.log('AUTHORIZATION');
       });
       
       Ti.Geolocation.addEventListener('location', function(e) {
           console.log('LOCATION: ' + JSON.stringify(e));
       });
       
       win.open();
       
    tiapp.xml
       <ios>
              <plist>
                  <dict>
                      <key>NSLocationAlwaysUsageDescription</key>
                      <string>Optional description here, can be empty</string>
                  </dict>
              </plist>
          </ios>
       

    Actual result

       [INFO] :   AUTHORIZATION
       [INFO] :   AUTHORIZATION
       [INFO] :   LOCATION: {"code":0,"success":true,"coords":{"timestamp":1410567849959,"altitude":23.712186813354492,"speed":-1,"latitude":37.3895378112793,"longitude":-122.05012512207031,"accuracy":65,"altitudeAccuracy":10,"heading":-1},"bubbles":true,"type":"location","source":{},"cancelBubble":false}
       [INFO] :   LOCATION: {"code":0,"success":true,"coords":{"timestamp":1410567849961,"altitude":23.712186813354492,"speed":-1,"latitude":37.3895378112793,"longitude":-122.05012512207031,"accuracy":65,"altitudeAccuracy":10,"heading":-1},"bubbles":true,"type":"location","source":{},"cancelBubble":false}
       [INFO] :   LOCATION: {"code":0,"success":true,"coords":{"timestamp":1410567850001,"altitude":23.712186813354492,"speed":-1,"latitude":37.3895378112793,"longitude":-122.05013275146484,"accuracy":68.14575958251953,"altitudeAccuracy":11.721681594848633,"heading":-1},"bubbles":true,"type":"location","source":{},"cancelBubble":false}
       [INFO] :   LOCATION: {"code":0,"success":true,"coords":{"timestamp":1410567850005,"altitude":23.712186813354492,"speed":-1,"latitude":37.3895378112793,"longitude":-122.05013275146484,"accuracy":68.14575958251953,"altitudeAccuracy":11.721681594848633,"heading":-1},"bubbles":true,"type":"location","source":{},"cancelBubble":false}
       [INFO] :   AUTHORIZATION_ALWAYS
       
    tested environment Mac osx 10.9.4 Maverics Appcelerator Studio, build: 3.4.0.201409112242 Titanium SDK, build: 3.4.0.v20140912160914 acs@1.0.16 alloy 1.5.0-rc install@0.1.7 npm@1.4.23 sudo@1.0.3 titanium 3.4.0-rc2 titanium-code-processor@1.1.1 Xcode6 Device: iPhone 5S iOS8
  8. Malcolm Hollingsworth 2014-09-13

    Not sure if this requires a new ticket - so someone advice; I have the same permission issues but for Beacons, they fall into the Geo family if I am correct. I have zero problems on iOS7 xcode 5, but iOS8 xcode 6 nothing - permission warning "Location services not authorised" stops everything in its tracks. I have added the extra tiapp.xml ios entries noted above and in the example app and included the button to test the current state - it shows the "AUTHORIZATION_UNKNOWN" entry. But then requesting the beacon ranging and such does not trigger a permission dialog. If I use the Apple settings app and change the permission manually the beacons are found. So this must be a simple lack of triggering in the mix.
  9. Ingo Muschenetz 2014-09-13

    Comment from [~cng]. Thoughts appreciated: In this ticket, app triggers for location service authorization only when developer calls getCurrentPosition(). Similarly, TIMOB-17665 also wants to trigger for location service authorization when userLocation is set. And now, from [~core13]'s description, beacon needs this authorization too. I’m just thinking if we should just create a new general method called requestLocationServicesAuthorization(authorizationType). And update titanium documents to inform developers to call this method whenever location services is required for iOS8. This way it will cover the above scenarios, including others we may not have explicitly covered.
  10. Jon Alter 2014-09-19

    This implementation works fine for now. Lets close this ticket and create a new linked ticket to improve it as mentioned above.
  11. Stephen Feather 2014-09-23

    Jon, Do we have a new ticket to watch regarding the beacon permissions?
  12. Jon Alter 2014-09-23

    [~sfeather] TIMOB-17742
  13. Olga Romero 2014-09-23

    Closing as fixed, tested using Mac osx 10.9.5 Mavericks Appcelerator Studio, build: 3.4.0.201409161950 Titanium SDK, build: 3.4.0.v20140923111716 acs@1.0.16 alloy 1.5.0-rc2 install@0.1.7 npm@1.4.23 sudo@1.0.3 titanium 3.4.0-rc4 titanium-code-processor@1.1.1 Xcode6.0.1 (6A317) Devices: iPhone 6 iOS 8 iPhone 6+ iOS 8
  14. Stephen Feather 2014-09-24

    thank you john.

JSON Source