1. There are two ways to achieve background positioning: standard location service (calling CLLocationManager's startUpdatingLocation) significant-change location service (calling CLLocationManager's startMonitoringSignificantLocationChanges) 2. The difference between the two: The former (startUpdatingLocation) is standard positioning. To use it in the background, you must add the Required background modes attribute in the info.plist file and select the App registers for location updates value. The former (startUpdatingLocation) may be suspended or terminated by the system due to resource problems when running in the background, but it will be called once there is an update. However, when the system is still resource tight during the update, it will be called with a delay. Delegate. If you have high real-time requirements, this may not be suitable, and it will be difficult to control the performance of the user's machine. The former (startUpdatingLocation) will not be awakened again if it is manually closed by the user. The former positioning is based on gps/base station/wifi positioning. Which CoreLocation framework is used has its own set of rules. The latter (startMonitoringSignificantLocationChanges) uses base station positioning, so the device must have a phone module. The xx attribute can be set in the plist to limit the devices that can be downloaded and installed. The latter (startMonitoringSignificantLocationChanges) will be awakened to call the delegate whether it is in the background or manually closed by the user. There are only 3 ways to prevent its update. (1) The user turns off positioning services (2) The user turns off positioning services for the app (3) The device is in airplane mode or cannot turn on the necessary hardware (guessed it is the hardware of the positioning module). When will the latter (startMonitoringSignificantLocationChanges) be updated? It is updated when the base station is replaced. So the update frequency is related to the base station density. Urban areas are updated more frequently than suburban areas. Therefore, many students said that there was no update because they were still within the same group of base stations. The former consumes more power and has higher accuracy than the latter. 3. Common features between the two: Both call back the same delegate method when updating location information: -(void)locationManager:(CLLocationManager )manager didUpdateLocations:(NSArray )locations; 4. Upload information: Due to the background Tasks are only allocated a limited time to perform necessary operations, so if they are not completed before the timeout (such as a network request), the app will be terminated. Here is a method to apply for an extra 10 minutes for you to perform the desired operation and apply for a background task: beginBackgroundTaskWithExpirationHandler (I won’t go into details, you can check the information on how to use it). 5. Summary: Both methods have advantages and disadvantages, which are determined according to the usage scenario. Apps running in the foreground usually require accurate real-time positioning and have limited running time. Consider using the first standard positioning, such as navigation applications. If the movement speed is fast (the distance changes obviously) and the positioning (monitoring) is required for a long time, the latter can be considered, such as a taxi-hailing application. Quoted from here
1. There are two ways to achieve background positioning:
standard location service (calling CLLocationManager's startUpdatingLocation)
significant-change location service (calling CLLocationManager's startMonitoringSignificantLocationChanges)
2. The difference between the two:
The former (startUpdatingLocation) is standard positioning. To use it in the background, you must add the Required background modes attribute in the info.plist file and select the App registers for location updates value.
The former (startUpdatingLocation) may be suspended or terminated by the system due to resource problems when running in the background, but it will be called once there is an update. However, when the system is still resource tight during the update, it will be called with a delay. Delegate. If you have high real-time requirements, this may not be suitable, and it will be difficult to control the performance of the user's machine.
The former (startUpdatingLocation) will not be awakened again if it is manually closed by the user.
The former positioning is based on gps/base station/wifi positioning. Which CoreLocation framework is used has its own set of rules.
The latter (startMonitoringSignificantLocationChanges) uses base station positioning, so the device must have a phone module. The xx attribute can be set in the plist to limit the devices that can be downloaded and installed.
The latter (startMonitoringSignificantLocationChanges) will be awakened to call the delegate whether it is in the background or manually closed by the user. There are only 3 ways to prevent its update. (1) The user turns off positioning services (2) The user turns off positioning services for the app (3) The device is in airplane mode or cannot turn on the necessary hardware (guessed it is the hardware of the positioning module).
When will the latter (startMonitoringSignificantLocationChanges) be updated? It is updated when the base station is replaced. So the update frequency is related to the base station density. Urban areas are updated more frequently than suburban areas. Therefore, many students said that there was no update because they were still within the same group of base stations.
The former consumes more power and has higher accuracy than the latter.
3. Common features between the two:
Both call back the same delegate method when updating location information: -(void)locationManager:(CLLocationManager )manager didUpdateLocations:(NSArray )locations;
4. Upload information:
Due to the background Tasks are only allocated a limited time to perform necessary operations, so if they are not completed before the timeout (such as a network request), the app will be terminated. Here is a method to apply for an extra 10 minutes for you to perform the desired operation and apply for a background task: beginBackgroundTaskWithExpirationHandler (I won’t go into details, you can check the information on how to use it).
5. Summary:
Both methods have advantages and disadvantages, which are determined according to the usage scenario. Apps running in the foreground usually require accurate real-time positioning and have limited running time. Consider using the first standard positioning, such as navigation applications. If the movement speed is fast (the distance changes obviously) and the positioning (monitoring) is required for a long time, the latter can be considered, such as a taxi-hailing application.
Quoted from here