3

As per the WWDC video, https://developer.apple.com/videos/play/wwdc2019/705/, when you ask for "AlwaysAuthorization" permission you will see only "When In Use, Once and Don't allow". Even if you tap on "When In Use", the delegate call back will come back as kCLAuthorizationStatusAuthorizedAlways. This is working as expected. But is there a way to find out that the request is still provisional or actually-always-allow?

There is no enum associated to this permission. The only allowed enums are:

kCLAuthorizationStatusNotDetermined, kCLAuthorizationStatusDenied, kCLAuthorizationStatusAuthorizedAlways, kCLAuthorizationStatusAuthorizedWhenInUse

Because I want to show an alert as soon as user grants the "While In Use" permission, to tell them that the app will only work if you provide "Always Allow" via system preferences and I can navigate them to the system settings page of my app via a tap, just like how Zenly is doing it: https://www.macrumors.com/2019/08/16/app-developers-tracking-restrictions-ios-13/

nr5
  • 4,228
  • 8
  • 42
  • 82
  • No, that is the point of the change. Apple will determine when it is an appropriate time to prompt the user to grant increased location permissions. – Paulw11 Aug 28 '19 at 09:47
  • Then the only way would be to show this alert to an iOS 13+ user who logs in for a first time app launch? – nr5 Aug 28 '19 at 09:56
  • Also, that article is a little misleading; it isn't that there is no "always" option, you just don't get it straight away. The user is prompted after some time. You could try a dialog but I suspect that Apple will reject apps that do that if they wanted apps to have always immediately why would they have gone to the trouble of making this change. – Paulw11 Aug 28 '19 at 09:57
  • I understand the always dialog and it does come up as soon as a background activity such as geofence activated. But for a new user who has just granted the location as When in use, as soon as you put the app in background, the updates stop. Imagine a location tracking app, which the user will download and allow the while in use permission and start walking with app in bg. By the time the recording and a probable walk has already been started but the location updates will stop unless that provisional alert comes up. Leaving the app with no data for that amount of time. – nr5 Aug 28 '19 at 10:02
  • The appropriate response in that scenario is to set `allowsBackgroundLocationUpdates` to `true`. That way your app will receive location updates in the background and the user will be aware that your app is using their location via the blue bar. There is no reason for an app that needs location during a walk needs the user's location *always* – Paulw11 Aug 28 '19 at 10:10
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/198579/discussion-between-paulw11-and-nr5). – Paulw11 Aug 28 '19 at 10:24
  • Granting an app "always" permission on the off chance that they might be going for a hike seems like the sort of abuse that Apple is trying to cut down on. Surely the user *knows* that they are starting on a hike and can go into your app to tell it. At that point all your app needs is when in use permission and background mode on the location manager. The blue bar will also prompt them to end their hike in your app when they are done. – Paulw11 Aug 28 '19 at 10:28
  • Exactly people who are on long hikes do not bother to open the app every time similarly my other app which tracks daily commute is even more in favor of this use case. No one will ever bother to open the app before they start a car or get on a subway. – nr5 Aug 28 '19 at 11:12

1 Answers1

1

You can check if you're getting location updates in the background for more than 10 seconds after the application gets in the background. If yes, then you have the permanent Allow Always. If not, then you have the provisional Allow Always (or any other authorization that you can check explicitly).

Dmitry
  • 527
  • 5
  • 13
  • Yes, this does crossed my mind but once you are in background, the only thing which you can do is send a local notification to the user. I want to engage the user at the very start of the app, just like how zenly app did it(the link which I shared in my question) – nr5 Aug 29 '19 at 01:51
  • I love the suggestion, but location updates continue for about 5 seconds in `While In Use` mode and `Provisional Always` mode. So, `Provisional Always` cannot be determined using this method. – William Grand Sep 18 '19 at 12:07
  • 1
    Please do the same but wait more than 10 seconds (for example, 15 seconds). This works fine. – Dmitry Sep 18 '19 at 16:43