-3

Since apple has deferred the "Always Allow" permission and only OS can and will ask for that permission based on its own convenience, it is hard to understand what all the scenarios are.

If you see the WWDC video: https://developer.apple.com/videos/play/wwdc2019/705/

The guy clearly says at 04:14, "you ask for requestAlwaysAuthorization, apple provides you with the max option of "While In Use", but at the same time the delegate callback says, the app has "Always Allow permission"". This works as expected, and my app gets the location updates, only If I keep it opened. At 04:35 he says, start Geofence activity as a background-tracking/always-allow requirement. This is where it confuses me, If I put my app in background, location updates are stopped. Why am I asked to setup a geofence for a user who is already in motion even when my delegate call back received "Always Allow" permission?

At 05:22, the pop up which solidifies the provisional always allow permission only comes up (at OS convenience), when you lock the device and unlock it, after putting it in the background as discussed in above paragraph. But all the data in between is lost. My app tracks user's trips and this will completely kill the valid use case of recording user's movement in a vehicle.

Even if I follow the video and create a geofence when app goes to the background and then start to move, nothing happens until I lock and unlock the device. This seems to be pretty useless.

Desdenova
  • 5,326
  • 8
  • 37
  • 45
nr5
  • 4,228
  • 8
  • 42
  • 82

1 Answers1

2

Why am I asked to setup a geofence for a user who is already in motion even when my delegate call back received "Always Allow" permission?

You’re not. You’ve misunderstood the video. He gives that as an example of using Always powers. It’s just an example.

At 05:22, the pop up which solidifies the provisional always allow permission only comes up (at OS convenience), when you lock the device and unlock it, after putting it in the background as discussed in above paragraph. But all the data in between is lost.

No it isn’t. Listen to what he says in the video. If the user now accepts Always, the withheld delegate message is delivered.

this will completely kill the valid use case of recording user's movement in a vehicle.

No it won’t. That use case has nothing to do with anything you said previously. If your app is tracking location in the foreground and goes into the background with background location mode and keeps tracking, it is in use. So all you need for that is When In Use. So all that Always stuff is irrelevant to you.

That is the whole point of the video. Don’t ask for Always unless you need it. If you do ask for it, use it, or you won’t get it. But you, it appears, don’t need it.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • I receive always authorization callback in the code itself even when user taps " while in use" permission. And if that is the case my app is meant to track user as soon as you start moving with a certain speed. When that logic triggers and user puts the app in background, the updates are stopped. Locking and unlocking the device brings that pop up of "change to always allow" pop up. How funny is that? Tracking user's location while the app is in background is the "always powers" of my app and it was supposed to work that way when apple's core location api is sending me the "always" callback. – nr5 Aug 20 '19 at 17:40
  • I would encourage you to try it first. I can't even see the blue bar on the top which is normal for a "while in use" permission and the location updates are completely stopped as soon as you put the app in background mode. I wouldn't have asked the question before trying it. – nr5 Aug 20 '19 at 17:42
  • Well, could you show some code? You have to put the location manager into background mode just as you go into the background. – matt Aug 20 '19 at 17:52
  • I'll try to make a sample tomorrow. But I never had to put my location manager into background mode. Once I get the always auth. in did change authorization status, even if I put the app in bg, I get the updates. Its working out of the box that way in ios 12. Right now also I get the same delegate auth status back(as mentioned in the video), but the location updates are stopped as soon as you go to the bg mode. – nr5 Aug 20 '19 at 18:02
  • As a matter of fact my app uses geofence as well but only when required. When I already know user is driving I should not use it. – nr5 Aug 20 '19 at 18:04
  • Well so far it sounds to me like you were always doing it wrong in the past. Anyway I’m sticking with my answer. – matt Aug 20 '19 at 19:33
  • Nope. If that's the case I wouldn't have recorded and processed a million miles of data. The functionality is straight forward to get the best gps data possible whether the app is foreground or background and without user interaction (that's where geofence walks in). If I put the location manager in significant location mode for the background use case, all I'd get is gps data with lots of delay, which has no significance for my app that needs pin point gps coordinates. – nr5 Aug 21 '19 at 04:32
  • 1
    @nr5 I am also facing the same problem as you said. Did you find any alternative way to fix this ? To get location always even in background or foreground? – vinoth87 Oct 04 '19 at 11:13