0

if my app is requesting GPS location, there's a dialog shown to user asking permission. and my app also check the authorization, if the user not allow use location service, I will also prompt a dialog to notify user to do the settings.

now the question is, when I first launch the app, the user haven't allow yet, but the check code also executed, so it will show a dialog beneath the system privacy dialog. now it has two scenarios:

  1. user click Don't allow, the system dialog dismissed, and my dialog appear, say app don't have permission to locate, that's right.
  2. but if user click Allow, my will also shown because it's right there, beneath the system's dialog.

I now can only put the two part code different place, but is there a better or more reasonable way to solve this? which is, if user clicked allow, I will know.

some thoughts: 1. if I can know there's a system's privacy dialog been presenting (not a better way, because I just want to know location privacy 2. how to know the location privacy dialog's presenter, so I will use it to check if it has presenting a dialog 3. how to know what action did user do after the privacy dialog is shown can user clicked to dismiss.

walker
  • 627
  • 1
  • 6
  • 19

1 Answers1

0

Implement didChangeAuthorizationStatus delegate method from location manager and check authorization there

func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
switch status {
case .NotDetermined:
    // show alert here
    break
case .AuthorizedWhenInUse:

    break
case .AuthorizedAlways:

    break
case .Restricted:
      // show alert here

    break
case .Denied:
      // show alert here
    break
default:
    break
}
}
Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
  • yeah, seems I ask question too soon and haven't explore the document enough, my bad, I dived into view hierarchy to solved the propblem – walker Dec 19 '17 at 11:15