0

In my iOS application, I want to fetch the user's current location. Before fetching the location I am calling below method to check whether location services has been enabled from settings or not.

[CLLocationManager locationServicesEnabled];

I want to show a customized error message to user if the settings is turned off. But before showing my alert itself, Apple is showing one pop-up like below.

enter image description here

My customer does not require the settings button here. Is there any way I can disable this system level pop-up. If not disable, can I hide the settings button from the alert? Please help in this. Thank You...

Rashmi Ranjan mallick
  • 6,390
  • 8
  • 42
  • 59

2 Answers2

2

You cann't do this. If you try to do this apple will reject your app. Check this Doc1, doc2

Update Read this topic Location-Based Services

Mani
  • 17,549
  • 13
  • 79
  • 100
  • So, if I click on cancel button instead of settings button in the alert and try to access the location once again... then what will happen? – Rashmi Ranjan mallick Dec 19 '13 at 07:40
  • You have to manually open setting app and click to `yes`. That means, user haven't interest to share his location and your app don't force user to share to his location. You have to think about this and you can manually check user authorization and switch to setting app from anywhere. – Mani Dec 19 '13 at 07:55
  • That is true.. But in this case I have to do it from 2nd time onwards. Isn't it? Because when the settings is disabled, iOS shows the pop-up for the first time. How to actually know that I have to show my customized alert now or handle it in other way? – Rashmi Ranjan mallick Dec 19 '13 at 08:37
  • I think you didn't get my question. Because iOS is handling the error condition for the first time, I do not have to show it for the first time. How do I know that this is not the first time. – Rashmi Ranjan mallick Dec 19 '13 at 09:29
  • I already told you, check `authorization status`. Check this method `[CLLocationManager authorizationStatus]` this link too https://developer.apple.com/library/mac/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/doc/c_ref/CLAuthorizationStatus – Mani Dec 19 '13 at 09:32
  • Can you please show me the code snippet to handle this. In my case, if the location is turned off when trying to fetch location, this pop-up is coming. When I cancel the pop-up and again try to access location, then it is showing the same pop-up for second time. But, next time onwards there is no pop-up when I repeat this. How to handle this. – Rashmi Ranjan mallick Dec 19 '13 at 13:43
  • look Melih Mucuk's answer in this http://stackoverflow.com/questions/15153074/checking-location-service-permission-on-ios. and see this too http://stackoverflow.com/questions/5655674/opening-the-settings-app-from-another-app – Mani Dec 19 '13 at 13:48
1

Location warnings are the requests made by apps (such as Camera, Compass, and Maps as well as location-based third-party apps) to use Location Services with those apps. An app will present a location warning the first time it needs to access Location Services data. Tapping OK will give that app permission to use Location Services as needed. Tapping Don't Allow will prevent an app from accessing Location Services data from then on.

You can't disable this location service alert. It is a system system generated one.

manujmv
  • 6,450
  • 1
  • 22
  • 35