ios9定位服务的app进入后台三分钟收不到经纬度,应用被挂起问题及解决方案

Posted walkerwqp

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ios9定位服务的app进入后台三分钟收不到经纬度,应用被挂起问题及解决方案相关的知识,希望对你有一定的参考价值。

原来定位服务是10分钟收不到定位信息就挂起定位,现在变为最短3分钟,估计都是为了省电吧。只要你开启应用的后台定位,并且10分钟有一次定位,那么苹果就不会关闭你的线程,现在变成3分钟。若你的应用开启了后台定位,当最短3分钟(经过测试也可能大于3分钟小于等于10分钟)不定位,ios系统也会把你的应用挂起。而高德地图ios sdk的ios9以上版本后台定位开启方法变更,而高德导航库没有同步变更,导致使用老的地图库和高德导航地图库的用户定位服务不能实际开启,切换到后台3分钟(经过测试也可能大于3分钟小于等于10分钟)没有实际定位请求,被ios系统认为是伪定位服务的应用并挂起线程。而高德定位模块也有问题,有时间也有不定位的情况。如:手机开启后台定位的应用,网络连接wifi(aibinjian)切换到后台,当用户移动到wifi覆盖区外,那么应用收到网络异常通知,手机的网络自动切换到4g手机网络,应用没有收到网络正常通知,导致应用在8分钟后不定位,并且应用被系统干掉。当手机没有网络时高德也不定位,而原生态的定位在有网和无网络的情况下都能定位,所以还是用原生态的定位更靠谱。 
高德地图iOS SDK V2.5.0版本提供后台持续定位的能力,即便你的app退到后台,且位置不变动时,也不会被系统挂起,可持久记录位置信息。该功能适用于记录轨迹录或者出行类App司机端。

只需要您的做以下几步操作:

1.添加代码。

对于iOS9之前的系统:


_mapView.pausesLocationUpdatesAutomatically = NO; 
对于iOS9(含)以上系统:


_mapView.allowsBackgroundLocationUpdates = YES;

若你的应用有3D地图和导航地图,那么你的应用用的应该是导航地图,若想用定位由于导航地图没有更新,估计你的应用没有allowsBackgroundLocationUpdates 这个属性,只能让你发愁了。

高德导航地图库千呼万换始终不出来,需要后台定位服务的应用不可能等待这个大爷吧!只能用替代方案了。开启原生态的定位服务,只是不用原生态的位置,能够保证高德地图一致获取到经纬度,仍旧用高德的经纬。原生态的位置服务只是触发高德地图收到经纬度和保持后台定位。

<code class="hljs objectivec has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">
<span class="hljs-class" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">@interface</span> <span class="hljs-title" style="box-sizing: border-box; color: rgb(102, 0, 102);">mainViewController</span>()<<span class="hljs-title" style="box-sizing: border-box; color: rgb(102, 0, 102);">NoticeCarViewDelegate</span>,<span class="hljs-title" style="box-sizing: border-box; color: rgb(102, 0, 102);">UIAlertViewDelegate</span>,<span class="hljs-title" style="box-sizing: border-box; color: rgb(102, 0, 102);">ServicingViewDelegate</span>,<span class="hljs-title" style="box-sizing: border-box; color: rgb(102, 0, 102);">MAMapViewDelegate</span>,<span class="hljs-title" style="box-sizing: border-box; color: rgb(102, 0, 102);">AMapSearchDelegate</span>,<span class="hljs-title" style="box-sizing: border-box; color: rgb(102, 0, 102);">UIActionSheetDelegate</span>,<span class="hljs-title" style="box-sizing: border-box; color: rgb(102, 0, 102);">PlaceSearchDeleagte</span>,<span class="hljs-title" style="box-sizing: border-box; color: rgb(102, 0, 102);">CLLocationManagerDelegate</span>></span>
{

    CLLocationManager *_locationManager;
}

- (<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span>)initAMapProperty
{
    FLDDLogDebug(@<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"函数"</span>);
    _locationManager = [[CLLocationManager alloc] init];
    _locationManager<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.delegate</span> = <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">self</span>;

    _locationManager<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.pausesLocationUpdatesAutomatically</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">NO</span>;
    <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">if</span> (IOS_VERSION_LARGE_OR_EQUAL(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">9.0</span>))
    {
        _locationManager<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.allowsBackgroundLocationUpdates</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">YES</span>;
    }

    <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">if</span> (![CLLocationManager locationServicesEnabled]) {
        <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">NSLog</span>(@<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"定位服务当前可能尚未打开,请设置打开!"</span>);
        <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">return</span>;
    }

    <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//如果没有授权则请求用户授权</span>
    <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">if</span> ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined)
    {
        [_locationManager requestAlwaysAuthorization];
    }
    <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">else</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">if</span>([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedAlways)
    {
        <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//设置代理</span>
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//        _locationManager.delegate = self;</span>
        <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//设置定位精度</span>
        _locationManager<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.desiredAccuracy</span> = kCLLocationAccuracyBest;
        <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//定位频率,每隔多少米定位一次</span>
        CLLocationDistance distance = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10.0</span>;<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//十米定位一次</span>
        _locationManager<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.distanceFilter</span> = distance;
        <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//启动跟踪定位</span>
        [_locationManager startUpdatingLocation];
        FLDDLogDebug(@<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"开启定位"</span>);
    }

<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//    //定位</span>
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//    _mapView.showsUserLocation = YES;</span>
    <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//地图跟着位置和方向移动</span>
    [_mapView setUserTrackingMode:MAUserTrackingModeFollow  animated:<span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">YES</span>];

    _mapView<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.showsCompass</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">NO</span>;
    <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//楼块隐藏</span>
    _mapView<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.buildingsDisabled</span>=<span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">YES</span>;
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//    //后台定位 可持久记录位置信息。高德地图iOS SDK V2.5.0版本提供后台持续定位的能力,即便你的app退到后台,且位置不变动时,也不会被系统挂起,可持久记录位置信息。该功能适用于记轨迹录或者出行类App司机端。</span>
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//    if (IOS_VERSION_LARGE_OR_EQUAL(9)) {</span>
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//        _mapView.allowsBackgroundLocationUpdates = YES;</span>
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//    }</span>
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//    else</span>
    {
        <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//由于IOS9中定位的授权机制改变 需要进行手动授权</span>
        _mapView<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.pausesLocationUpdatesAutomatically</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">NO</span>;
    }

    <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//不能旋转</span>
    _mapView<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.rotateEnabled</span>=<span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">NO</span>;
    _mapView<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.distanceFilter</span> = DISTANCE_FILTER;
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//    _mapView.desiredAccuracy = kCLLocationAccuracyHundredMeters;</span>
    <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//    mapView.showsScale = YES;</span>
    <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//    [mapView setZoomLevel:KmaxLEVEL animated:NO];</span>
    <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//自定义精度圈样式 去除精度圈</span>
    _mapView<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.delegate</span> = <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">self</span>;

    <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//纪录经纬度的数组</span>
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//    coordates = [[NSMutableArray alloc] init];</span>

}



<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">#pragma mark 定位回调 能获取到定位点的经纬度坐标</span>
- (<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span>)locationManager:(CLLocationManager *)manager didUpdateLocations:(<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">NSArray</span><CLLocation *> *)locations
{
    [locations enumerateObjectsUsingBlock:^(CLLocation * _Nonnull obj, NSUInteger idx, <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">BOOL</span> * _Nonnull stop) {
        FLDDLogDebug(@<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"obj.coordinate = %.f \n %.f"</span>,obj<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.coordinate</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.latitude</span>,obj<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.coordinate</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">.longitude</span>);
    }];
    FLDDLogDebug(@<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">""</span>);
}


</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li><li style="box-sizing: border-box; padding: 0px 5px;">20</li><li style="box-sizing: border-box; padding: 0px 5px;">21</li><li style="box-sizing: border-box; padding: 0px 5px;">22</li><li style="box-sizing: border-box; padding: 0px 5px;">23</li><li style="box-sizing: border-box; padding: 0px 5px;">24</li><li style="box-sizing: border-box; padding: 0px 5px;">25</li><li style="box-sizing: border-box; padding: 0px 5px;">26</li><li style="box-sizing: border-box; padding: 0px 5px;">27</li><li style="box-sizing: border-box; padding: 0px 5px;">28</li><li style="box-sizing: border-box; padding: 0px 5px;">29</li><li style="box-sizing: border-box; padding: 0px 5px;">30</li><li style="box-sizing: border-box; padding: 0px 5px;">31</li><li style="box-sizing: border-box; padding: 0px 5px;">32</li><li style="box-sizing: border-box; padding: 0px 5px;">33</li><li style="box-sizing: border-box; padding: 0px 5px;">34</li><li style="box-sizing: border-box; padding: 0px 5px;">35</li><li style="box-sizing: border-box; padding: 0px 5px;">36</li><li style="box-sizing: border-box; padding: 0px 5px;">37</li><li style="box-sizing: border-box; padding: 0px 5px;">38</li><li style="box-sizing: border-box; padding: 0px 5px;">39</li><li style="box-sizing: border-box; padding: 0px 5px;">40</li><li style="box-sizing: border-box; padding: 0px 5px;">41</li><li style="box-sizing: border-box; padding: 0px 5px;">42</li><li style="box-sizing: border-box; padding: 0px 5px;">43</li><li style="box-sizing: border-box; padding: 0px 5px;">44</li><li style="box-sizing: border-box; padding: 0px 5px;">45</li><li style="box-sizing: border-box; padding: 0px 5px;">46</li><li style="box-sizing: border-box; padding: 0px 5px;">47</li><li style="box-sizing: border-box; padding: 0px 5px;">48</li><li style="box-sizing: border-box; padding: 0px 5px;">49</li><li style="box-sizing: border-box; padding: 0px 5px;">50</li><li style="box-sizing: border-box; padding: 0px 5px;">51</li><li style="box-sizing: border-box; padding: 0px 5px;">52</li><li style="box-sizing: border-box; padding: 0px 5px;">53</li><li style="box-sizing: border-box; padding: 0px 5px;">54</li><li style="box-sizing: border-box; padding: 0px 5px;">55</li><li style="box-sizing: border-box; padding: 0px 5px;">56</li><li style="box-sizing: border-box; padding: 0px 5px;">57</li><li style="box-sizing: border-box; padding: 0px 5px;">58</li><li style="box-sizing: border-box; padding: 0px 5px;">59</li><li style="box-sizing: border-box; padding: 0px 5px;">60</li><li style="box-sizing: border-box; padding: 0px 5px;">61</li><li style="box-sizing: border-box; padding: 0px 5px;">62</li><li style="box-sizing: border-box; padding: 0px 5px;">63</li><li style="box-sizing: border-box; padding: 0px 5px;">64</li><li style="box-sizing: border-box; padding: 0px 5px;">65</li><li style="box-sizing: border-box; padding: 0px 5px;">66</li><li style="box-sizing: border-box; padding: 0px 5px;">67</li><li style="box-sizing: border-box; padding: 0px 5px;">68</li><li style="box-sizing: border-box; padding: 0px 5px;">69</li><li style="box-sizing: border-box; padding: 0px 5px;">70</li><li style="box-sizing: border-box; padding: 0px 5px;">71</li><li style="box-sizing: border-box; padding: 0px 5px;">72</li><li style="box-sizing: border-box; padding: 0px 5px;">73</li><li style="box-sizing: border-box; padding: 0px 5px;">74</li><li style="box-sizing: border-box; padding: 0px 5px;">75</li><li style="box-sizing: border-box; padding: 0px 5px;">76</li><li style="box-sizing: border-box; padding: 0px 5px;">77</li><li style="box-sizing: border-box; padding: 0px 5px;">78</li><li style="box-sizing: border-box; padding: 0px 5px;">79</li><li style="box-sizing: border-box; padding: 0px 5px;">80</li><li style="box-sizing: border-box; padding: 0px 5px;">81</li><li style="box-sizing: border-box; padding: 0px 5px;">82</li><li style="box-sizing: border-box; padding: 0px 5px;">83</li><li style="box-sizing: border-box; padding: 0px 5px;">84</li><li style="box-sizing: border-box; padding: 0px 5px;">85</li><li style="box-sizing: border-box; padding: 0px 5px;">86</li><li style="box-sizing: border-box; padding: 0px 5px;">87</li><li style="box-sizing: border-box; padding: 0px 5px;">88</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li><li style="box-sizing: border-box; padding: 0px 5px;">20</li><li style="box-sizing: border-box; padding: 0px 5px;">21</li><li style="box-sizing: border-box; padding: 0px 5px;">22</li><li style="box-sizing: border-box; padding: 0px 5px;">23</li><li style="box-sizing: border-box; padding: 0px 5px;">24</li><li style="box-sizing: border-box; padding: 0px 5px;">25</li><li style="box-sizing: border-box; padding: 0px 5px;">26</li><li style="box-sizing: border-box; padding: 0px 5px;">27</li><li style="box-sizing: border-box; padding: 0px 5px;">28</li><li style="box-sizing: border-box; padding: 0px 5px;">29</li><li style="box-sizing: border-box; padding: 0px 5px;">30</li><li style="box-sizing: border-box; padding: 0px 5px;">31</li><li style="box-sizing: border-box; padding: 0px 5px;">32</li><li style="box-sizing: border-box; padding: 0px 5px;">33</li><li style="box-sizing: border-box; padding: 0px 5px;">34</li><li style="box-sizing: border-box; padding: 0px 5px;">35</li><li style="box-sizing: border-box; padding: 0px 5px;">36</li><li style="box-sizing: border-box; padding: 0px 5px;">37</li><li style="box-sizing: border-box; padding: 0px 5px;">38</li><li style="box-sizing: border-box; padding: 0px 5px;">39</li><li style="box-sizing: border-box; padding: 0px 5px;">40</li><li style="box-sizing: border-box; padding: 0px 5px;">41</li><li style="box-sizing: border-box; padding: 0px 5px;">42</li><li style="box-sizing: border-box; padding: 0px 5px;">43</li><li style="box-sizing: border-box; padding: 0px 5px;">44</li><li style="box-sizing: border-box; padding: 0px 5px;">45</li><li style="box-sizing: border-box; padding: 0px 5px;">46</li><li style="box-sizing: border-box; padding: 0px 5px;">47</li><li style="box-sizing: border-box; padding: 0px 5px;">48</li><li style="box-sizing: border-box; padding: 0px 5px;">49</li><li style="box-sizing: border-box; padding: 0px 5px;">50</li><li style="box-sizing: border-box; padding: 0px 5px;">51</li><li style="box-sizing: border-box; padding: 0px 5px;">52</li><li style="box-sizing: border-box; padding: 0px 5px;">53</li><li style="box-sizing: border-box; padding: 0px 5px;">54</li><li style="box-sizing: border-box; padding: 0px 5px;">55</li><li style="box-sizing: border-box; padding: 0px 5px;">56</li><li style="box-sizing: border-box; padding: 0px 5px;">57</li><li style="box-sizing: border-box; padding: 0px 5px;">58</li><li style="box-sizing: border-box; padding: 0px 5px;">59</li><li style="box-sizing: border-box; padding: 0px 5px;">60</li><li style="box-sizing: border-box; padding: 0px 5px;">61</li><li style="box-sizing: border-box; padding: 0px 5px;">62</li><li style="box-sizing: border-box; padding: 0px 5px;">63</li><li style="box-sizing: border-box; padding: 0px 5px;">64</li><li style="box-sizing: border-box; padding: 0px 5px;">65</li><li style="box-sizing: border-box; padding: 0px 5px;">66</li><li style="box-sizing: border-box; padding: 0px 5px;">67</li><li style="box-sizing: border-box; padding: 0px 5px;">68</li><li style="box-sizing: border-box; padding: 0px 5px;">69</li><li style="box-sizing: border-box; padding: 0px 5px;">70</li><li style="box-sizing: border-box; padding: 0px 5px;">71</li><li style="box-sizing: border-box; padding: 0px 5px;">72</li><li style="box-sizing: border-box; padding: 0px 5px;">73</li><li style="box-sizing: border-box; padding: 0px 5px;">74</li><li style="box-sizing: border-box; padding: 0px 5px;">75</li><li style="box-sizing: border-box; padding: 0px 5px;">76</li><li style="box-sizing: border-box; padding: 0px 5px;">77</li><li style="box-sizing: border-box; padding: 0px 5px;">78</li><li style="box-sizing: border-box; padding: 0px 5px;">79</li><li style="box-sizing: border-box; padding: 0px 5px;">80</li><li style="box-sizing: border-box; padding: 0px 5px;">81</li><li style="box-sizing: border-box; padding: 0px 5px;">82</li><li style="box-sizing: border-box; padding: 0px 5px;">83</li><li style="box-sizing: border-box; padding: 0px 5px;">84</li><li style="box-sizing: border-box; padding: 0px 5px;">85</li><li style="box-sizing: border-box; padding: 0px 5px;">86</li><li style="box-sizing: border-box; padding: 0px 5px;">87</li><li style="box-sizing: border-box; padding: 0px 5px;">88</li></ul>

现在高德地图终于发布了新的支持ios9系统后台定位的导航地图包,并且发布了高德地图定位模块,支持一次定位的功能,能够一次定位到你的位置信息和cityCode。但是还存在应用在后台无网络不定位的可能被系统干掉的情况,建议仍旧ios原生定位的功能吧。

ios9.1以后,为了省电,应用切换到后台8分钟,不管是否是开启了后台定位服务,只要没有网络活动都有可能被挂起。所以你的应用切换到后台要保证8分钟之内有一次网络活动(如心跳等)。若用户打开应用去打电话,不知道网络没有了,等打10多分钟的电话,再去看应用,结果应用早挂了,这个问题很坑爹,暂时没有找到原因。不知道是高德定位搞的鬼还是最新的iphone系统的问题。估计是高德地图问题多些!

以上是关于ios9定位服务的app进入后台三分钟收不到经纬度,应用被挂起问题及解决方案的主要内容,如果未能解决你的问题,请参考以下文章

如何利用Java语言实现消息推送到手机app

高德地图收不到品牌定位怎么回事

app进入后台申请10分钟活跃时间-b

以 15 分钟的时间间隔在服务器上发送纬度和经度

微信小程序+腾讯地图 获取定位与地图选点插件

没有从后台服务获取纬度和经度