Skip to main content

Building menuboard detection with in-geofence tracking options

In this tutorial, we show you how to use in-geofence tracking options to build reliable, high-accuracy drive-thru menuboard detection while remaining battery efficient.

Steps#

Step 1: 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

Step 2: Create geofences#

There are several ways to create geofences:

  1. Create geofence page
  2. CSV import
  3. API

The tag is a group for the geofence. In this tutorial, we'll create two geofences for each drive-thru, a large circular geofence with radius 500m with tag ramp-up and a small, car-length polygon geofence in front of the menu board.

Step 3: Initialize the SDK#

Initialize the SDK with your publishable API key.

import UIKitimport RadarSDK
@UIApplicationMainclass AppDelegate: UIResponder, UIApplicationDelegate {  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {    Radar.initialize(publishableKey: "prj_test_pk_...")    Radar.setUserId("foo")
    return true  }
}

Step 4: Request foreground permissions#

import UIKitimport RadarSDKimport CoreLocation
@UIApplicationMainclass AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate {
  let locationManager = CLLocationManager()
  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {    Radar.initialize(publishableKey: "prj_test_pk_...")    Radar.setUserId("foo")
    self.locationManager.delegate = self    self.requestLocationPermissions()
    return true  }
  func requestLocationPermissions() {    let status = self.locationManager.authorizationStatus
    if status == .notDetermined {      self.locationManager.requestWhenInUseAuthorization()    }  }
}

Step 5. Configure remote tracking options#

In the Radar dashboard, navigate to the SDK configuration section in settings. Toggle on "Remotely set tracking options". Then toggle on "Enable on-trip tracking options" and set the "Tracking preset" to "Continuous". Toggle on "Enable in-geofence tracking options", set the "Tracking preset" to "Custom" and replace the JSON blob below with the following tracking options on iOS and Android respectively:

{  "desiredStoppedUpdateInterval": 3,  "desiredMovingUpdateInterval": 3,  "desiredSyncInterval": 2,  "desiredAccuracy": "high",  "stopDuration": 140,  "stopDistance": 70,  "sync": "all",  "replay": "stops",  "showBlueBar": true,  "useStoppedGeofence": true,  "stoppedGeofenceRadius": 100,  "useMovingGeofence": true,  "movingGeofenceRadius": 50,  "syncGeofences": true,  "useVisits": true,  "useSignificantLocationChanges": true,  "beacons": false}

In the field entitled "Geofence tags", input the tag of the geofence you created to trigger the increase in tracking frequency, ramp-up.

Step 6. 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.

let tripOptions = RadarTripOptions(externalId: "456")tripOptions.destinationGeofenceTag = "restaurant"tripOptions.destinationGeofenceExternalId = "123"tripOptions.mode = .carRadar.startTrip(options: tripOptions)

When a user is being tracked and enters the ramp-up geofence, the SDK will increase the frequency of location updates. With the frequency and accuracy of the ramped-up tracking, you can accurately detect when a users enters a car-length geofence in front of a menuboard.