> ## Documentation Index
> Fetch the complete documentation index at: https://docs.radar.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Building an app with location-enabled curbside pickup

In this tutorial, we show you how to use the Radar [iOS SDK](/sdk/ios), [geofences](/geofencing/geofences), and [trip tracking](/geofencing/trips) to build a "McRadar's" app with location-enabled curbside pickup.

## Languages used

* Swift

## Features used

* [iOS SDK](/sdk/ios)
* [Geofences](/geofencing/geofences)
* [Trip tracking](/geofencing/trips)

## Steps

<Steps>
  <Step title="Sign up for Radar">
    If you haven't already, sign up for Radar to get your API key. You can create up to 1,000 geofences and make up to 100,000 API requests per month for free.

    [**Get API keys**](https://radar.com/signup)
  </Step>

  <Step title="Import geofences">
    On the [Geofences page](https://dashboard.radar.com/geofencing/geofences), create a geofence for a McRadar's location. In this case, use `restaurant` for the geofence `tag` and `123` for the geofence `externalId`.
  </Step>

  <Step title="Install the Radar iOS SDK">
    [Install the Radar SDK](/sdk/sdk) using CocoaPods or Carthage (recommended) or by [downloading the framework](https://github.com/radarlabs/radar-sdk-ios/releases) and dragging it into your project.

    Initialize the SDK in your `AppDelegate` class with your publishable API key, then request location permissions.

    ```swift theme={null}
    import UIKit
    import CoreLocation
    import RadarSDK

    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {

        let locationManager = CLLocationManager()

        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            Radar.initialize(publishableKey: "prj_test_pk_...")

            self.locationManager.requestWhenInUseAuthorization()

            return true
        }

    }
    ```
  </Step>

  <Step title="Start tracking and start a trip">
    When the user places an order and taps "I'm on my way," start tracking to start live location tracking, start a trip to the destination geofence. Use the order ID, in this case `456`, for the trip `externalId`.

    Optionally, instead of calling `Radar.startTracking()`, we can simulate a sequence of location updates from an origin to a destination with `Radar.mockTracking()`. For example, to simulate a sequence of 10 location updates every 3 seconds by car from an `origin` to a `destination`, we can call:

    ```swift theme={null}
    Radar.mockTracking(
      origin: CLLocation(latitude: 40.714708, longitude: -74.035807),
      destination: CLLocation(latitude: 40.717410, longitude: -74.053334),
      mode: .car,
      steps: 10,
      interval: 3) { (status, location, events, user) in

    }
    ```

    ```swift theme={null}
    let tripOptions = RadarTripOptions(externalId: "456")
    tripOptions.destinationGeofenceTag = "restaurant"
    tripOptions.destinationGeofenceExternalId = "123"
    tripOptions.mode = .car
    Radar.startTrip(options: tripOptions, trackingOptions: .presetContinuous)
    ```
  </Step>

  <Step title="Display live ETAs in the trip tracking dashboard">
    Display live ETAs on the trip tracking dashboard, available on the [Enterprise](https://radar.com/pricing) plan. Or, display live ETAs in your own UI by polling the [list trips API](https://docs.radar.com/api#list-trips) or listening for [trip events](https://docs.radar.com/trip-tracking#trip-events) sent to a webhook.
  </Step>

  <Step title="Stop tracking and stop the trip">
    When the user taps "I'm here" or when the order is picked up, complete the trip and stop tracking.

    ```swift theme={null}
    Radar.completeTrip()
    Radar.stopTracking()
    ```
  </Step>
</Steps>

## Sample code

```swift theme={null}
// AppDelegate.swift

import UIKit
import CoreLocation
import RadarSDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    let locationManager = CLLocationManager()

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        Radar.initialize(publishableKey: "prj_test_pk_...")

        self.locationManager.requestWhenInUseAuthorization()

        return true
    }

}
```

```swift theme={null}
// ViewController.swift

import UIKit
import RadarSDK

class ViewController: UIViewController {

    var pickupStarted = false

    @IBAction func didTapButton(button: UIButton) {
        if !pickupStarted {
            let tripOptions = RadarTripOptions(externalId: "456")
            tripOptions.destinationGeofenceTag = "restaurant"
            tripOptions.destinationGeofenceExternalId = "123"
            tripOptions.mode = .car
            Radar.startTrip(options: tripOptions, trackingOptions: .presetContinuous)
            sender.setTitle("I'm here", for: .normal)
            pickupStarted = true
        } else {
            Radar.completeTrip()
            Radar.stopTracking()
            sender.setTitle("I'm here", for: .normal)
            pickupStarted = false
        }
    }

}
```

## Support

Have questions or feedback on this documentation? Let us know! Contact us at [radar.com/support](https://radar.com/support).
