4

I am having issue regarding significant-change location service.

Apple documentation says "Whether you use the standard location service or the significant-change location service to get location events, the way you receive those events is the same."

but in case of "significant-change location service" I am not able to get any callbacks which I get in case of "standard location service" Please let me know if anybody has any inputs?

CloudyMarble
  • 36,908
  • 70
  • 97
  • 130
Sagrian
  • 1,048
  • 2
  • 11
  • 29
  • its bcoz you get callback whenever significant change occurred in your location which can be in meters.and updatelocation will give you callback at every second or little more. – Dilip Manek Feb 05 '13 at 13:52
  • Don't sit on your system to wait for significant change. Have a coffee near by and get the significant change event. – Inder Kumar Rathore Feb 05 '13 at 13:56
  • I agree that there should be significant change to get the next callback, but don't you think it should at least come once when we start it. I mean there is nothing to compare whether significant change has occurred for first time? – Sagrian Feb 06 '13 at 05:30

1 Answers1

8

startUpdatingLocation updates the location when it is called first time and then when the distance filter value exceeds.

But the startMonitoringSignificantLocationChanges when a significant change in position occurs.

Please check CLLocationManager for the details.

startUpdatingLocation

Starts the generation of updates that report the user’s current location.

- (void)startUpdatingLocation Discussion

This method returns immediately. Calling this method causes the location manager to obtain an initial location fix (which may take several seconds) and notify your delegate by calling its locationManager:didUpdateLocations: method. (In iOS 5 and earlier, the location manager calls the locationManager:didUpdateToLocation:fromLocation: method instead.) After that, the receiver generates update events primarily when the value in the distanceFilter property is exceeded. Updates may be delivered in other situations though. For example, the receiver may send another notification if the hardware gathers a more accurate location reading.

Calling this method several times in succession does not automatically result in new events being generated. Calling stopUpdatingLocation in between, however, does cause a new initial event to be sent the next time you call this method.

If you start this service and your application is suspended, the system stops the delivery of events until your application starts running again (either in the foreground or background). If your application is terminated, the delivery of new location events stops altogether. Therefore, if your application needs to receive location events while in the background, it must include the UIBackgroundModes key (with the location value) in its Info.plist file.

In addition to your delegate object implementing the locationManager:didUpdateLocations: method, it should also implement the locationManager:didFailWithError: method to respond to potential errors.


startMonitoringSignificantLocationChanges

Starts the generation of updates based on significant location changes.

- (void)startMonitoringSignificantLocationChanges Discussion

This method initiates the delivery of location events asynchronously, returning shortly after you call it. Location events are delivered to your delegate’s locationManager:didUpdateLocations: method. The first event to be delivered is usually the most recently cached location event (if any) but may be a newer event in some circumstances. Obtaining a current location fix may take several additional seconds, so be sure to check the timestamps on the location events in your delegate method.

After returning a current location fix, the receiver generates update events only when a significant change in the user’s location is detected. For example, it might generate a new event when the device becomes associated with a different cell tower. It does not rely on the value in the distanceFilter property to generate events. Calling this method several times in succession does not automatically result in new events being generated. Calling stopMonitoringSignificantLocationChanges in between, however, does cause a new initial event to be sent the next time you call this method.

If you start this service and your application is subsequently terminated, the system automatically relaunches the application into the background if a new event arrives. In such a case, the options dictionary passed to the locationManager:didUpdateLocations: method of your application delegate contains the key UIApplicationLaunchOptionsLocationKey to indicate that your application was launched because of a location event. Upon relaunch, you must still configure a location manager object and call this method to continue receiving location events. When you restart location services, the current event is delivered to your delegate immediately. In addition, the location property of your location manager object is populated with the most recent location object even before you start location services.

In addition to your delegate object implementing the locationManager:didUpdateLocations: method, it should also implement the locationManager:didFailWithError: method to respond to potential errors.

Note: Apps can expect a notification as soon as the device moves 500 meters or more from its previous notification. It should not expect notifications more frequently than once every five minutes. If the device is able to retrieve data from the network, the location manager is much more likely to deliver notifications in a timely manner.

Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • Mithun, I am using older version of iOS and in that instead of `locationManager:didUpdateLocations:` I am using `- (void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation`. I have already gone through the documentation and according to it for both type of location services, the way you receive those events is the same. The method that you mentioned is for iOS 6 and later. The one that I am using is supported from iOS 4 onwards. – Sagrian Feb 06 '13 at 05:37
  • My locationManager: delegate method doesn't fire if my app enters in the background mode. I have added all the required keys in the info.plist but still no change. Please share your thoughts on this issue. Im using iOS 9.1 with xcode 7.2 . Im using startUpdatingLocation. – Md Rais Jan 12 '16 at 14:58
  • Can one use both `startUpdatingLocation` and `startMonitoringSignificantLocationChanges` in the application together at the same time? – irbanana Apr 23 '18 at 07:28
  • @irbanana: Yes, but what is the use of that ? Whenever a location change occurs, because of `startUpdatingLocation` it will invoke the delegate methods. In that case there is no significance for using `startMonitoringSignificantLocationChanges` – Midhun MP Apr 23 '18 at 10:16
  • @MdRais, do you has been turned on 'Background -> location updates' on Capabilities? – ihsan_husnul Jan 15 '19 at 09:03