【发布时间】:2014-10-25 19:55:37
【问题描述】:
我正在编写一个类似于Chris Alvares daemon 的守护进程。我想在未经用户许可的情况下在后台获取设备位置。如果“设置”中的Location Services 首选项设置为ON,那么获取位置没有问题。为此,我将布尔值设置为 true 添加到我的可执行权利 com.apple.locationd.preauthorized 键中。问题是当Location Services 关闭时。在这种情况下,当我想获取设备位置时,会弹出 UIAlertView 告诉用户位置服务已关闭。基本上有两种方法,但我不知道它们是否可行。首先,以编程方式打开/关闭设置中的定位服务首选项。其次,使用其他代码获取位置,无需设置 Locations Services ON
更新 01:
我按照 iMokhles 所说的做了,我想它应该可以工作,但没有任何反应。我想这是因为权利,我看到了系统日志,这是记录的内容:
iPhone locationd[44] <Error>: Entitlement com.apple.locationd.authorizeapplications required to use _CLDaemonSetLocationServicesEnabled
iPhone myDaemon[3443] <Error>: CoreLocation: CLInternalSetLocationServicesEnabled failed
所以我将此密钥添加到权利中,但它仍然给了我这个错误。在我检查了 Preferences app entitlement 后,我将这些行添加到了 entitlements plist 中,但仍然没有任何反应。
<key>com.apple.locationd.authorizeapplications</key>
<true/>
<key>com.apple.locationd.defaults_access</key>
<true/>
<key>com.apple.locationd.effective_bundle</key>
<true/>
<key>com.apple.locationd.status</key>
<true/>
【问题讨论】:
标签: ios geolocation jailbreak iphone-privateapi location-services