[TIMOB-25739] iOS 11: Location permissions do not indicate missing "WhenInUse" privacy-key
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-02-01T14:39:38.000+0000 |
Affected Version/s | Release 6.3.0, Release 7.0.1 |
Fix Version/s | Release 7.1.0 |
Components | iOS |
Labels | ios, ios11, location, permissions |
Reporter | Daniel Falcon |
Assignee | Hans Knöchel |
Created | 2018-02-01T09:09:24.000+0000 |
Updated | 2018-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
File | Date | Size |
---|---|---|
app.js | 2018-02-01T09:07:48.000+0000 | 425 |
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 mentionNSLocationAlwaysAndWhenInUseUsageDescription
twice. So as a workaround, simple add theNSLocationWhenInUseUsageDescription
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 yourPR: https://github.com/appcelerator/titanium_mobile/pull/9789
Hi Hans, Indeed, adding the missing NSLocationWhenInUseUsageDescription fixes the issue. Thanks for the quick answer!
PR already merged and the permissions and error message are now accurate and improved.