因为业务需求,项目需要一直定位物流司机位置。主要难点就是APP最小化进入后台,自动被系统挂起,定位停止。
网上找了很多教程,各种不一样,经过多次试验,踩过N多坑,现发出来共享一下。
1. 开启后台定位模式

PS:开启后,系统也会在plist中自动插入

2 .请求授权
因为苹果加强对用户隐私保护,要使用定位服务,必须先在系统配置文件Info.plist定义Key,用以提醒用户为何使用定位服务


3 .具体实现代码
导入头文件,创建管理者

请求定位

实现代理方法

本文标题:IOS后台持续定位
本文链接:https://www.haomeiwen.com/subject/khcqzttx.html
网友评论