简体   繁体   English

iphone / ipad dev - 如何以编程方式启动系统设置应用程序

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

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? 如何在我的应用程序中以编程方式执行此操作?

As of iOS 5.0 you can open the settings app programmatically using the "prefs://" URL scheme. 从iOS 5.0开始,您可以使用“prefs://”URL方案以编程方式打开设置应用程序。 You are out of luck on earlier versions. 你在早期版本上运气不好。

If you just use location services by [CLLocationManager startUpdatingLocation] it will automatically pop up the alert you describe if Location Services are disabled. 如果您只是通过[CLLocationManager startUpdatingLocation]使用位置服务,它将自动弹出您描述的警报,如果禁用了位置服务。

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). 但是,当您的特定应用程序被用户拒绝使用位置服务时,无法强制显示警报(在iOS 4中通过在位置设置中禁用您的应用程序,在iOS 3中通过在前2次启动时拒绝CoreLocation请求)该应用程序)。 You only receive the kCLErrorDenied error in -locationManager:didFailWithError:. 您只在-locationManager中收到kCLErrorDenied错误: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. 在这种情况下,Maps.app确实显示了带有“设置”按钮的警报,但看起来他们正在使用私有API。

I didn't finish reading the whole question! 我没读完整个问题!

However, see: Programmatically opening the settings app (iPhone) 但是,请参阅:以编程方式打开设置应用程序(iPhone)

(Original reply: The Settings app doesn't seem to have a custom URL scheme, so it appears that the answer is "no".) (原始回复:“设置”应用似乎没有自定义网址方案,因此似乎答案为“否”。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM