iOS9 Location Services app into the background three minutes without latitude and longitude, application is suspended problems and solutions

Source: Internet
Author: User

The original location service is 10 minutes not receiving positioning information on the suspended positioning, now become the shortest 3 minutes, is expected to save power bar.

Only if you start the app's background targeting and you have a location for 10 minutes, then Apple won't shut down your thread. Now it's 3 minutes. If your app turns on background targeting, the iOS system will also suspend your app when the shortest 3 minutes (measured by a test may be greater than 3 minutes or less than 10 minutes) are not positioned.

And the iOS9 of the iOS SDK version number above the background location open method changes, and the German navigation library is not synchronized changes, resulting in the use of the old map Library and the German navigation map library user Location Services can not actually open, Switch to the background for 3 minutes (the test may be more than 3 minutes less than or equal to 10 minutes) without the actual location request, the iOS system feels that the app is pseudo-location service and hangs the thread. And the German positioning module also has a problem. There are situations where there is time and no positioning. such as: Mobile phone to open the background location of the application. Network Connected WiFi (Aibinjian) switches to the background when the user moves outside of the WiFi coverage area. Then the app receives a network exception notification. Mobile phone network itself to switch to 4g mobile phone network, the application did not receive the network normal notification, resulting in the application in 8 minutes after the location, and the application was killed by the system. When the mobile phone does not have a network, and no positioning, and the original ecological positioning in the network and network-free situation can be positioned. So it is more reliable to use the original ecological positioning.
The German map iOS SDK V2.5.0 version number provides background persistence, even if your app is back in the background. And the position is not changed. Will not be suspended by the system and can record location information persistently. This function is suitable for recording tracks or travel-type app drivers.

You only need to do the following steps:

1. Add the code.

For systems prior to iOS9:

1
_mapview.pauseslocationupdatesautomatically = NO;
For IOS9 (inclusive) systems:

1
_mapview.allowsbackgroundlocationupdates = YES;

If your app has a map and a navigation map, then your app should be a navigation map, if you want to use location because the navigation map is not updated. It is expected that your application will not allowsbackgroundlocationupdates this attribute, just to make you worry.

The German navigation map Library thousand call million change always does not come out. Applications that require background location services can't wait for this big uncle. It's only possible to use alternative solutions.

Open the original ecological location services, just not the original ecological position. Can ensure that the German map to achieve the same latitude and longitude, still use the gold and longitude. The pristine location service simply triggers the gold map to receive latitude and longitude and maintain background positioning.

 @interface mainviewcontroller() <noticecarviewdelegate,uialertviewdelegate ,servicingviewdelegate,mamapviewdelegate,amapsearchdelegate,  Uiactionsheetdelegate,placesearchdeleagte,cllocationmanagerdelegate>{Cllocationmanager *_locationmanager;} - (void) initamapproperty{Flddlogdebug (@"function");    _locationmanager = [[Cllocationmanager alloc] init]; _locationmanager. Delegate= Self; _locationmanager. pauseslocationupdatesautomatically=NO;if(Ios_version_large_or_equal (9.0)) {_locationmanager. Allowsbackgroundlocationupdates=YES; }if(! [Cllocationmanager locationservicesenabled]) {NSLog(@"Location service may not be open at this moment, please set it open!" ");return; }//Assume that no authorization is required for user authorization    if([cllocationmanager authorizationstatus] = = kclauthorizationstatusnotdetermined)    {[_locationmanager requestalwaysauthorization]; }Else if([cllocationmanager authorizationstatus] = = kclauthorizationstatusauthorizedalways) {//Set up proxy//_locationmanager.delegate = self;        //Set positioning accuracy_locationmanager. Desiredaccuracy= Kcllocationaccuracybest;//positioning frequency, positioning every few metersCllocationdistance distance =10.0;//10 m positioning once_locationmanager. Distancefilter= distance;//Start tracking location[_locationmanager startupdatinglocation]; Flddlogdebug (@"Enable positioning"); }//// positioning//_mapview.showsuserlocation = YES;    //Map moves with position and direction[_mapview Setusertrackingmode:mausertrackingmodefollow Animated:YES]; _mapview. Showscompass=NO;//Block Hide_mapview. buildingsdisabled=YES;///// background positioning can record location information persistently. The German map iOS SDK V2.5.0 version number provides background persistence, even if your app is back in the background. And the position is not changed. Will not be suspended by the system and can record location information persistently. This function is suitable for recording tracks or travel-type app drivers. //if (Ios_version_large_or_equal (9)) {//_mapview.allowsbackgroundlocationupdates = YES;//    }//Else{//Due to a change in the IOS9 authorization mechanism, manual authorization is required_mapview. pauseslocationupdatesautomatically=NO; }//cannot be rotated_mapview. rotateenabled=NO; _mapview. Distancefilter= Distance_filter;//_mapview.desiredaccuracy = Kcllocationaccuracyhundredmeters;    //Mapview.showsscale = YES;    //[Mapview setzoomlevel:kmaxlevel animated:no];    //self-defining precision circle style to remove the precision Circle_mapview. Delegate= Self;//array of longitude and latitude//Coordates = [[Nsmutablearray alloc] init];}#pragma mark position callback to get the latitude and longitude coordinates of the anchor point- (void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (Nsarray<cllocation *> *) locations{[Locations enumerateobjectsusingblock:^ (cllocation * _nonnull obj, NSUInteger idx,BOOL* _nonnull stop) {Flddlogdebug (@"obj.coordinate =%.f \%.f"Obj. Coordinate. LatitudeObj. Coordinate. Longitude);    }]; Flddlogdebug (@"");}

Now the GAO de map finally unveiled a new navigation map package that supports IOS9 system background positioning. and announced the German map positioning module. Support one-time positioning function, you can navigate to your location information and Citycode. If you need to always agree to the location of your app, then use iOS native location and the location of the German map!

Prevent the re-emergence of the High German map does not correctly start the app's positioning function.

After ios9.1, in order to save electricity. The app switches to the background for 8 minutes. Whether or not the background location service is turned on, it is possible to suspend only if there is no network activity (targeting activity is possible). So your app switches to the back office to ensure that there is a network activity (such as heartbeat, etc.) within 8 minutes. If the user opens the app to call. Do not know that the network has not, and so on more than 10 minutes of phone calls, and then to see the application, the results of the application early hanging, the problem is very pit dad, temporarily did not find the reason. I don't know if it's a ghost or a problem with the latest iphone system. It is expected that there will be more problems with the German map.
Now by launching the mobile phone native positioning function and the gold background positioning function, to ensure that our always-positioned app, in the background not to be killed.

iOS9 Location Services app into the background three minutes without latitude and longitude, application is suspended problems and solutions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.