-3

My problem is that , i have 2 permission request for the user upon installing the app.

First: Location Permission
Second: Push Notifications

Problem: When the user installed the app, it will show the location notification first, then after miniseconds, it will show the push notification premission. after we select from the options in push notification, it will then show the location notification.

How can i delay showing the push notification permission so that the user can select on the location permission request first?

Sample pseudo code
-> Normal Location Request [CLLocationManager] without if / else
-> Normal push notification request

I want it to be like

if (**user selects option in location request**) //either allow or not
   show push notification request
l_na_l
  • 190
  • 1
  • 14
  • did you just read my post ? "How can i delay showing the push notification permission so that the user can select on the location permission request first?" so i'm asking if it is possible to know if the user selected an option in the location permission request so that i can put my push notification request there. please read it first. – l_na_l Feb 19 '18 at 01:14
  • yap. that was sarcastic. meaning that he get's the question while saying that it is not clear – l_na_l Feb 19 '18 at 01:19
  • Well this is not a good place for sarcasm. – matt Feb 19 '18 at 01:20
  • If your application uses push notification, it will be first to be prompt to user. You can always wait to get permission for location access from user on demand. When you need to ask for user's permission you can use this - [ locationManager requestWhenInUseAuthorization]; [ locationManager requestAlwaysAuthorization]; – Shawon91 Feb 19 '18 at 04:53
  • thanks @Shawon91. this answer is better than the mocking one – l_na_l Feb 19 '18 at 07:02
  • Glad could help....... Welcome – Shawon91 Feb 19 '18 at 09:02

3 Answers3

0

"Waiting" for the user to respond to a location permission request is quite tricky, because the API is very badly structured. Instead of this sort of thing (pseudocode):

requestAuthorization { status in
    if status == .authorized

...you are forced just to call requestAuthorization without any result or completion handler.

The way out of the quandary is to implement the delegate method locationManager(_:didChangeAuthorization:). That is where you learn that you have been authorized (if you weren't already). So, in your implementation of that method, that is where you would ask for the push notification authorization (under the right circumstances).

Barring that, I would just suggest that you rethink your architecture so that you ask for location authorization and push authorization at completely different points in your app's lifespan so that they cannot overlap in this nondeterministic way.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • the thing is , i want to show the other permission request even though the user decline the permission for Location – l_na_l Feb 19 '18 at 01:15
  • 1
    That's a good objection! But you have no way of knowing that that has happened. You don't have any way to know that the authorization dialog appears or when it has been dismissed (esp. if the authorization did not change). As I said, the API for location authorization is badly structured. – matt Feb 19 '18 at 01:17
  • You can always check if user has denied location access permission using CLLocation manager delegate, For push notification access status you can check the url - https://stackoverflow.com/questions/35126361/ios-9-how-to-detect-when-user-said-dont-allow-to-the-push-notification-reque – Shawon91 Feb 19 '18 at 04:58
0

You have to add a key in your plist file to access location services image

rxtr007
  • 121
  • 4
0

If your application uses push notification, it will be first to be prompt to user. You can always wait to get permission for location access from user on demand. When you need to ask for user's permission you can use this - [ locationManager requestWhenInUseAuthorization]; [ locationManager requestAlwaysAuthorization];

Shawon91
  • 200
  • 3
  • 9