Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25739] iOS 11: Location permissions do not indicate missing "WhenInUse" privacy-key

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2018-02-01T14:39:38.000+0000
Affected Version/sRelease 6.3.0, Release 7.0.1
Fix Version/sRelease 7.1.0
ComponentsiOS
Labelsios, ios11, location, permissions
ReporterDaniel Falcon
AssigneeHans Knöchel
Created2018-02-01T09:09:24.000+0000
Updated2018-02-23T22:58:53.000+0000

Description

When asking for Location permissions in iOS 11, the following error is shown, even thought my plist already have these keys:
[ERROR] :  The NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationAlwaysUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription key must be defined in your tiapp.xml in order to request this permission.
This is the ios part of the tiapp.xml. I've also opened the generated Info.plist file and it looks good.
<ios>
        <enable-launch-screen-storyboard>true</enable-launch-screen-storyboard>
        <use-app-thinning>true</use-app-thinning>
        <plist>
            <dict>
                <key>NSLocationAlwaysUsageDescription</key>
                <string>Can we use geolocation?</string>
                <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
                <string>Can we use geolocation?</string>
                <key>UISupportedInterfaceOrientations~iphone</key>
                <array>
                    <string>UIInterfaceOrientationPortrait</string>
                </array>
                <key>UISupportedInterfaceOrientations~ipad</key>
                <array>
                    <string>UIInterfaceOrientationPortrait</string>
                </array>
                <key>UIRequiresPersistentWiFi</key>
                <false/>
                <key>UIPrerenderedIcon</key>
                <false/>
                <key>UIStatusBarHidden</key>
                <false/>
                <key>UIStatusBarStyle</key>
                <string>UIStatusBarStyleDefault</string>
            </dict>
        </plist>
    </ios>
In order to reproduce the issue, this is an example code, on an normal app, inside app.js (I've also attached the file)
var win = Ti.UI.createWindow({layout:'vertical'});
var label = Ti.UI.createLabel({top:30,width:'90%',height:Ti.UI.SIZE});

win.addEventListener('open',function(){
	Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e){ apiInfo(JSON.stringify(e)); });
});

function apiInfo(msg) {
	Titanium.UI.createAlertDialog({
		title: "info",
		message:msg
	}).show();
};

win.add(label);
win.open();
Thanks for having a look

Attachments

FileDateSize
app.js2018-02-01T09:07:48.000+0000425

Comments

  1. Hans Knöchel 2018-02-01

    Investgating now, keeping this ticket updated. *EDIT*: It requires the "WhenInUse" description NSLocationWhenInUseUsageDescription permission to be set as well, which should also be in the error message that has a typo in it to mention NSLocationAlwaysAndWhenInUseUsageDescription twice. So as a workaround, simple add the NSLocationWhenInUseUsageDescription as well and I'll adjust the core to fix the alert. And thinking about it, I don't remember why I've made the "WhenInUse" key required for "Always" use-cases, it shouldn't even be used. So probably that will go away as well. *EDIT 2*: I remember why! Apple [documents](https://developer.apple.com/documentation/corelocation/choosing_the_authorization_level_for_location_services/requesting_always_authorization) to have all three flags set because the user can downgrade permissions in iOS 11 due to privacy "improvements". I'll fix the typo inside the error anyway. Quote Apple: {quote} Add the NSLocationWhenInUseUsageDescription key and the NSLocationAlwaysAndWhenInUseUsageDescription key to your Info.plist file. (Xcode displays these keys as "Privacy - Location When In Use Usage Description" and "Privacy - Location Always and When In Use Usage Description" in the Info.plist editor.) {quote} Summary: Add the following key to your section in the tiapp.xml and you'll have a good life:
       <key>NSLocationWhenInUseUsageDescription</key>
       <string>Can we access your location when using the app</string>
       
  2. Hans Knöchel 2018-02-01

    PR: https://github.com/appcelerator/titanium_mobile/pull/9789
  3. Daniel Falcon 2018-02-01

    Hi Hans, Indeed, adding the missing NSLocationWhenInUseUsageDescription fixes the issue. Thanks for the quick answer!
  4. Eric Wieber 2018-02-23

    PR already merged and the permissions and error message are now accurate and improved.

JSON Source