iphone/ipad dev - how to launch the system settings app programmatically

ぐ巨炮叔叔 提交于 2019-12-23 12:18:08

问题


In the settings -> general, there is a switch to turn on/off the location services. In the Maps app, when location services is off, if the user click on the find me button, it pops up an alert and asks the user to turn on location services in the settings. It then exits the app and launch the settings app. How can I do that programmatically in my app?


回答1:


As of iOS 5.0 you can open the settings app programmatically using the "prefs://" URL scheme. You are out of luck on earlier versions.




回答2:


If you just use location services by [CLLocationManager startUpdatingLocation] it will automatically pop up the alert you describe if Location Services are disabled.

However, there's no way to force showing the alert when your specific app has been rejected from using location services by the user (in iOS 4 by disabling your app in the location settings, in iOS 3 by denying the CoreLocation request at the first 2 starts of the app). You only receive the kCLErrorDenied error in -locationManager:didFailWithError:.

Maps.app does show the alert with a Settings button in this case but it looks like they're using a private API for that.




回答3:


I didn't finish reading the whole question!

However, see: Programmatically opening the settings app (iPhone)

(Original reply: The Settings app doesn't seem to have a custom URL scheme, so it appears that the answer is "no".)



来源:https://stackoverflow.com/questions/3017719/iphone-ipad-dev-how-to-launch-the-system-settings-app-programmatically

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