how to request the user to turn on location services

拜拜、爱过 提交于 2019-12-02 22:32:00

问题


I need my app to access the user's current location. It checks at the beginning of the app if the user has it set or not. and if not i need the app to show a prompt for it to use location services. Like a an alert view and on lick of the button it should take you to the screen of location services on iphone.


回答1:


You can check the for locationServicesEnabled and if the location service is allowed for your application by this code:

if([CLLocationManager locationServicesEnabled] && [CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied) {
    //do your works
} else {
   //show an alert
}


来源:https://stackoverflow.com/questions/25018784/how-to-request-the-user-to-turn-on-location-services

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