Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-25322] iOS: Geolocation should be able to handle iOS 11 permission upgrade #9458

Closed
wants to merge 12 commits into from

Conversation

hansemannn
Copy link
Collaborator

JIRA: https://jira.appcelerator.org/browse/TIMOB-25322

Unit-Tests not possible as it require's UI-interaction with the confirmation-dialog. Might be a good candidate for UI-tests in our Appium test-suite.

@jvandijk
Copy link

@hansemannn I understand that you choose to be backwards compatible, but this is not going to work out if you want to support iOS 11 from a functional perspective. If you go for the permission upgrade strategy, then this will work now in iOS11, but on iOS 10 you don't get the chance to upgrade. You'll have to add quite some checks on the javascript side to be back- and forwards compatible. Question is why you weren't allowed to upgrade before? This is quite odd.... isn't it?

@hansemannn
Copy link
Collaborator Author

hansemannn commented Sep 22, 2017

@jvandijk From my understanding, this was not technically possible from Apple's side before, so we guarded it in the past. If it was, we can remove those guards for a better code-structure. The iOS < 11 checks for incremental updates are correct and seem to be necessary from what I know by now.

[locationManager requestWhenInUseAuthorization];
} else {
NSLog(@"[ERROR] The keys NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription are not defined in your tiapp.xml. Starting with iOS8 this is required.");
if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorizedAlways &&

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect addition! Already ran into issues in the past due to this 'auto' permission request logic.

@jvandijk
Copy link

I've been testing this way of implementing it and also ran into the fact that the didChangeAuthorizationStatus is firing on showing the 2nd authorization request. The code in that method is also not capable of handling the authorization, and could fire the callback unnecessary.

@hansemannn
Copy link
Collaborator Author

@jvandijk You mean upgrading the permissions on iOS < 11? So it's not worth looking into it in the SDK? I really focussed on the iOS 11 changes for this one. For the changes, I can also think of two ones for the client (if you want the improved UX):

Normal geo-request:

  1. If iOS < 11: Request Always-Auth
  2. Else: Request When in Use

Going background / Always-auth / geofencing:

  1. If iOS >= 11: Request Always-Auth
  2. No change for iOS < 11 required

@jvandijk
Copy link

No it is worth looking into the SDK, because I experienced this on iOS 11 indeed. The didChangeAuthorizationStatus fired, and resulted in a callback on which I execute new things in the client. This then results in the 2nd upgrade permissions request just to give a visual flash.... and disappear again without the user being able to select a new level. And you can only trigger every permission request once.... resulting in a weird UX.

@hansemannn
Copy link
Collaborator Author

hansemannn commented Sep 25, 2017

Can you shoot me a test-case? EDIT: PR updated and tested against iOS 10.x and iOS 11. Seems to work! 🙏 Also improved the warn-message when calling location-services without permissions to print a well-formatted log of options.

@hansemannn
Copy link
Collaborator Author

@jvandijk Ping?

@jvandijk
Copy link

@hansemannn Sorry, was too busy with other things. In my situation I add an eventlistener to the resume event (coming back from the permission dialog) and in that eventlistener verify if the permission has been set to update the button state. That's the only difference from the described testcase on Jira.

@hansemannn
Copy link
Collaborator Author

No worries. Did you test the latest version?

@jvandijk
Copy link

Tested with 6.2.2

@hansemannn
Copy link
Collaborator Author

I mean, did you test the latest PR changes?

@jvandijk
Copy link

jvandijk commented Oct 5, 2017

@hansemannn I have just one more concern... and that's the hasLocationPermissions method. When checking WHEN_IN_USE but the user has given ALWAYS should iOS 11 or greater then return true or false?

@hansemannn
Copy link
Collaborator Author

Good question. I think it should / could show a warning but return false, because the actual permission does not match the one being requested. Does this behave different for iOS 11 / < 11?

@jvandijk
Copy link

jvandijk commented Oct 6, 2017

It does not behave differently, just that always now implicitly means that you have when in use as well because you're able to upgrade.

@hansemannn
Copy link
Collaborator Author

That‘s correct, but if you want to check that permission, you would explicitly ask for it. In other words: I cannot see a use-use where this would fail.

Copy link
Contributor

@vijaysingh-axway vijaysingh-axway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@hansemannn
Copy link
Collaborator Author

@ewieberappc Just resolved a linting-issue, so this is now definitely ready for QE 🙂.

@tidev tidev deleted a comment from build Oct 12, 2017
@build
Copy link
Contributor

build commented Oct 12, 2017

Warnings
⚠️

🔬 There are library changes, but no changes to the unit tests. That's OK as long as you're refactoring existing code

Generated by 🚫 dangerJS

@ewieberappc
Copy link
Contributor

When following the steps from the ticket, I get an error that the NSLocationWhenInUseUsageDescription key must be defined. It seems that NSLocationAlwaysAndWhenInUseUsageDescription is not covering the "just when-in-use" request case.

@hansemannn
Copy link
Collaborator Author

@ewieberappc Can you send me your test project?

@hansemannn
Copy link
Collaborator Author

Closing this one in favor of the above linked one that handles this one + more improvements regarding the new auth-flow and the requirement of the when-in-use key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants