Timothy Rajan
Timothy Rajan

Reputation: 1957

iOS- How to avoid the dialog "Would like to use your current location"

In my app, one of my input is to get the location of the user as well as the contacts of the user. This is done from the code.

When the user runs the app for the first time,they get a dialog

"AppName" would like to use your current location. I wish to avoid this dialog since this is an important data and dont want the users to accidently press "Dont Allow"

How to avoid this dialog. Could any one please let me know. Thanks

Upvotes: 0

Views: 5111

Answers (5)

Marko Hlebar
Marko Hlebar

Reputation: 1973

Basically if you are using the CLLocationManager to get the user's location, you can't. The user must allow your app to use location services. I think you could go around this by just dropping a pin on the map. For instance when you want the user to pick the location, you show the map and let the user tap where their location is, but that is not really user friendly :)

I will elaborate the process above, so that even if the user doesn't allow location services, you can get the users location manually. First you set up your CLLocationManager

_manager = [[CLLocationManager alloc] init];
_manager.delegate = self;
[_manager startUpdatingLocation];

and then you can observe it's delegate method

-(void) locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
    if (kCLAuthorizationStatusAuthorized == status) {
       //the app is authorized to use GPS
    }
    else {
        //show map for manual location picking.
    }
}

Hope this helps you to make some decisions.

Upvotes: 1

ZeMoon
ZeMoon

Reputation: 20274

You cant make use of location services or contacts without explicit permission from the user.

However, you can check for these permissions and tell the user that these services need to be allowed for them to use it properly.

Try looking at this answer for how to do that: Checking for iOS Location Services

Upvotes: 4

amonxu
amonxu

Reputation: 349

I think it's not allowed in ios. the prompt is useful for use to know what permission of the app. like map, photo and so on.

Upvotes: 1

rambo
rambo

Reputation: 61

You can not dude, app will have to display the dialog

Upvotes: 1

Mani
Mani

Reputation: 17585

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

Upvotes: 3

Related Questions