Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19850] iOS: Permissions (Geolocation) Bugs in implementation & documentation

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-11-04T04:08:27.000+0000
Affected Version/sRelease 5.1.0
Fix Version/sRelease 5.1.0, Release 5.2.0
ComponentsiOS
Labelspermissions
ReporterFokke Zandbergen
AssigneeHans Knöchel
Created2015-11-03T09:43:23.000+0000
Updated2015-11-20T23:27:31.000+0000

Description

While working on the permissions sample app I ran into some irregularities: * The API reference for [hasLocationPermissions](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Geolocation-method-hasLocationPermissions) lists all AUTHORIZATION_* constants as possible values, while only AUTHORIZATION_ALWAYS and AUTHORIZATION_WHEN_IN_USE are valid. * The API reference for [requestLocationPermissions](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Geolocation-method-requestLocationPermissions) lists all AUTHORIZATION_* constants as possible values, while only AUTHORIZATION_ALWAYS and AUTHORIZATION_WHEN_IN_USE are valid. * The implementation of [requestLocationPermissions](https://github.com/appcelerator/titanium_mobile/blob/1607237763f9e490e41d98b8d711ac49eeb01043/iphone/Classes/GeolocationModule.m#L879-L884) seems to call the locationPermissionManager twice if the first statement is false:
            if (currentPermissionLevel == kCLAuthorizationStatusAuthorizedWhenInUse) {
                NSLog(@"[ERROR] cannot change already granted permission from AUTHORIZATION_WHEN_IN_USE to AUTHORIZATION_ALWAYS");
            } else {
                [[self locationPermissionManager] requestAlwaysAuthorization];
            }
            [[self locationPermissionManager] requestAlwaysAuthorization];
* On Android Ti.Calendar.requestCalendarPermissions, Ti.Contacts.requestContactsPermissions and Ti.Media.requestCameraPermissions will call back with success:false if the required permission is missing in tiapp.xml but on iOS Ti.Geolocation.requestLocationPermissions will not call back at all when the required NSLocation*UsageDescription key is missing in tiapp.xml. It should call back with success:false as well. * If you don't allow permission when asked by Ti.Calendar.requestCalendarPermissions or Ti.Contacts.requestContactsPermissions it will call back with success:false but Ti.Geolocation.requestLocationPermissions does not call back at all. * For both hasLocationPermissions and requestLocationPermissions wouldn't the expected behaviour be that if AUTHORIZATION_ALWAYS was granted then AUTHORIZATION_WHEN_IN_USE would be seen as granted as well since always > when in use?

Comments

  1. Fokke Zandbergen 2015-11-03

    Ti 5.1.0 sample app for testing: https://github.com/appcelerator-developer-relations/appc-sample-ti510/blob/master/app/controllers/permissions.js
  2. Hans Knöchel 2015-11-04

    All changes implemented, except of the "auto grant when-in-use, if always was granted before" since that is no bug but a question on how to check the permissions. In my opinion, a user requests either when-in-use or always on one use case, not both. And if so, the users can now check against this, but we don't do it automatically. PR master: https://github.com/appcelerator/titanium_mobile/pull/7395 PR 5_1_X: https://github.com/appcelerator/titanium_mobile/pull/7396
  3. Chee Kiat Ng 2015-11-04

    CR and FT passed. PRs merged.
  4. Harry Bryant 2015-11-06

    Verified as fixed, using the permissions sample app, tested that permissions were correctly requested and granted. Verified that this was reflected under Settings > Privacy. Setting the permissions to deny the app will cause the app to request permission access again. Tested on: iPhone 6S+ iOS 9.1 Device & iPhone 6 iOS 9.1 Sim Mac OSX El Capitan 10.11 (15A284) Ti SDK: 5.1.0.v20151104190037 Appc NPM: 4.2.1 Appc CLI: 5.1.0-43 Ti CLI: 5.0.4 Alloy: 1.7.23 Xcode 7.1(7B91b) Node v0.12.7 production Closing ticket.

JSON Source