Jenn Eve Jenn Eve - 1 year ago 83
iOS Question

location based push notification when app is not running?

Is it possible when your app is not running but the user is still able to receive a push notifcation when he's near a particular location. This will require checking of the user's current latitude and longitude (even app is not running).

If it's possible, can you give some guidelines on how can I achieve it?

Answer Source

There are two methods you can make use of to track user location even when the app is not running:

  1. Significant-location change service.

    Call the method startMonitoringSignificantLocationChanges in a CLLocationManager instance. This will help significantly in saving the power but it does not provide with high precision compared to the second method below.

    You do not need to set the location key in UIBackgroundModes if you opt for this method.

  2. Standard location service.

    Call the method startUpdatingLocation in a CLLocationManager instance. This takes a lot of device power but it provides higher precision. Remember to set location key in UIBackgroundModes to make sure the tracking is still working even if the app is killed.

You can use either one of the methods above. I use the first method combined with Region Monitoring to trigger local notification.

You can take a look at the following Apple documentation for a more thorough explanations and examples:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download