"IOS9 on the problem of positioning, there is a bad news a good news" bad news: If not fit iOS9, you can not sneak in the background (without blue bar, see picture)! Good news: This scenario will be allowed: multiple location managers in the same app: some can only be located in the foreground, others can be located in the background, and can be turned on or off in the background of a particular location manager at any time.
If you do not have permission to request background targeting, you can also locate it in the background, but with a blue bar:
How to secretly locate in the background: Request Background Location permissions:
1. Instantiating the location Manager
_locationmanager = [[Cllocationmanager alloc] init];
2. Set up Proxy
_locationmanager.delegate = self;
3. Positioning accuracy
[_locationmanager Setdesiredaccuracy:kcllocationaccuracybest];
4. Request user rights: Divided into:? Only in the foreground to open the location, can also be located in the background,
Note: It is recommended to request only one, if two permissions are required, only request?
//?? This order will result in a bug: After the first start of the program, the system will only request the permissions of the?, the permission system will not be requested, only the next time the app is launched to request?
if ([[[[Uidevice Currentdevice] systemversion] Floatvalue] >= 8) {
[_locationmanager requestwheninuseauthorization];//? Only open the location at the front desk
[_locationmanager requestalwaysauthorization];//? can also be located in the background
}
5.ios9 new Features: This scenario will be allowed: multiple location managers in the same app: some can only be located in the foreground, others can be located in the background (and can be disabled at any time in the background location).
if ([[[[Uidevice Currentdevice] systemversion] Floatvalue] >= 9) {
_locationmanager.allowsbackgroundlocationupdates = YES;
}
6. Update user Location
[_locationmanager startupdatinglocation];
But if you try this way, and you don't configure info.plist,100%, your program crashes and you get an error:
Assertion failure in-[cllocationmanager setallowsbackgroundlocationupdates:],/buildroot/library/caches/ com.apple.xbs/sources/corelocationframework_sim/corelocation-1808.1.5/framework/corelocation/ cllocationmanager.m:593
To configure the Info.plist as follows:
The corresponding Info.plist XML source code is:
How to secretly locate in the background: Request Background Location permissions: