我从这里下载项目
https://www.raywenderlich.com/136165/core-location-geofencing-tutorial
并根据要求进行了少量修改
隐私权-位置始终且在使用时用法说明
隐私权-使用时的位置使用情况说明
GeotificationsViewController
中,我对此进行了修改func locationManager(_管理器:CLLocationManager,didChangeAuthorization状态:CLAuthorizationStatus){
mapView.showsUserLocation =状态== .authorizedAlways ||状态== .authorizedWhenInUse
当我授予
authorizedAlways
时,一切正常,但授予authorizedWhenInUse
时,它未传递didEnterRegion
和didExitRegion
在两种情况下,应用程序均处于打开状态,正在运行,处于 Activity 状态且在屏幕上可见。
xcode版本9.2,
iOS 11.2
最佳答案
对于基于区域的监视操作,您必须要收集用户的authorizedAlways
权限。
有关更多参考,请检查此。
https://developer.apple.com/documentation/corelocation/cllocationmanager/1620562-requestwheninuseauthorization
应用程序不能使用任何自动重新启动应用程序的服务,例如
作为区域监视或重要的位置更改服务。
关于ios - 在iOS 11中,当被授予authorizedWhenInUse时,didEnterRegion和didExitRegion不起作用,否则可以正常工作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48094118/