Location Tracking

Implement the tracking of user's location in your iOS App


To enable location tracking, select your project from the Project Navigator, choose your application’s target, open the Capabilities tab, and within Background Modes, add the following capability:

  • Location updates

You can also specify this key directly through your Info.plist as follow:


The Woosmap SDK needs Always authorization for Woosmap to work. If your app did not ask the user for the required permission, you need to add a usage description to your app’s Info.plist before requesting permission. The usage description explains why the application requires authorization. Add the NSLocationWhenInUseUsageDescription key to your Info.plist file, to define the string informing the user why you need the location services. For example:

<string>Allow app to access your location while you are using it</string>

To get access to location when the app is in the background, add the NSLocationAlwaysAndWhenInUseUsageDescription key to your Info.plist file.

<string>Allow app to access your location even when you are not using it</string>

The location services must themselves currently be enabled for the system. A request for user authorization is displayed automatically when your app first attempts to use location services.

Woosmap Permission

You should ask your users to give access Woosmap to collect their location activity. This should be done the first time the app is launched or when the user wants to change his status. This setting is saved on our side.

  • Declare the following import
    import WoosmapNow
    import CoreLocation
  • Authorize Woosmap if Location Tracking is enabled
    if CLLocationManager.authorizationStatus() == .notDetermined {
      Now.shared.updateUserTracking(tracking: true)

If tracking is set to true and if your user has not yet authorized your app to fetch locations, Woosmap will ask for it and start monitoring location changes.

Tracking Location

The Location Tracking starts after calling Now.shared.startMonitoringInBackground().

Calling startMonitoringInBackground() before setting tracking will stop Woosmap execution.

This method should be called each time your app is launched.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {     
    if (CLLocationManager.authorizationStatus() == .authorizedAlways) {
    return true

func applicationDidEnterBackground(_ application: UIApplication) {
    if CLLocationManager.authorizationStatus() != .notDetermined {

To avoid loosing data, call Now.shared.willTerminate() in the proper AppDelegate method:

func applicationWillTerminate(_ application: UIApplication) {

func applicationDidEnterBackground(_ application: UIApplication) {
   if CLLocationManager.authorizationStatus() != .notDetermined {

Next Step

Congratulations! You have now successfully integrated Woosmap Mobile SDK with your iOS app and are now sending user data to Woosmap. We suggest you proceed to read the next section to learn how to Integrate push messaging.