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

半城伤御伤魂 提交于 2019-12-12 00:28:16

问题


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


回答1:


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




回答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




回答3:


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




回答4:


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.




回答5:


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.



来源:https://stackoverflow.com/questions/20536476/ios-how-to-avoid-the-dialog-would-like-to-use-your-current-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!