最近的需要用到后台持续定位,项目中又是用的百度地图API,遇到点麻烦:
1、进入后台,手机静置,定位持续16分钟左右就停止了,但是还是无限后台效果;但如果一直运动,让定位持续更新,定位服务一直保持
其实是API中的自动暂停定位属性 默认是true,设置为false,就不会自动关闭了
_locService = BMKLocationService()
_locService!.delegate = self
// 允许后台定位 打开
_locService!.allowsBackgroundLocationUpdates = true
// 自动暂停定位 关闭
_locService!.pausesLocationUpdatesAutomatically = false
//启动LocationService
_locService!.startUserLocationService()
记得设置Background Modes:
下面是AppDelegate中进入后台后的处理办法ÿ