> ## 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 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

<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="Create geofences">
    There are several ways to create geofences:

    1. [Create geofence page](https://dashboard.radar.com/geofencing/geofences/new)
    2. [CSV import](/geofencing/geofences#csv-import)
    3. [API](/api#upsert-a-geofence)

    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>

  <Step title="Initialize the SDK">
    Initialize the SDK with your publishable API key.

    <CodeGroup>
      ```swift Swift theme={null}
      import UIKit
      import RadarSDK

      @UIApplicationMain
      class AppDelegate: UIResponder, UIApplicationDelegate {
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
          Radar.initialize(publishableKey: "prj_test_pk_...")
          Radar.setUserId("foo")

          return true
        }

      }
      ```

      ```kotlin Kotlin theme={null}
      import io.radar.sdk.Radar

      class MyApplication : Application() {

        override fun onCreate() {
          super.onCreate()

          Radar.initialize(this, "prj_test_pk...")
          Radar.setUserId("foo")
        }

      }
      ```

      ```react React Native theme={null}
      import React, { useState, useEffect } from "react";
      import Radar from "react-native-radar";

      export default function App() {
        Radar.initialize("prj_live_pk_...");
        
        useEffect(() => {
          Radar.setUserId(userId)
        }, [userId]);

        return (
          <div id="content">
          </div>
        );
      }
      ```
    </CodeGroup>
  </Step>

  <Step title="Request foreground permissions">
    <CodeGroup>
      ```swift Swift theme={null}
      import UIKit
      import RadarSDK
      import CoreLocation

      @UIApplicationMain
      class 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()
          }
        }

      }
      ```

      ```kotlin Kotlin theme={null}
      import android.Manifest
      import android.app.AlertDialog
      import android.content.pm.PackageManager
      import android.os.Build

      import androidx.core.app.ActivityCompat

      import io.radar.sdk.Radar

      class MainActivity : AppCompatActivity() {
        private val foregroundLocationPermissionsRequestCode = 1

        override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)

          Radar.initialize(this, "prj_test_pk_...")
          Radar.setUserId("foo")

          requestLocationPermissions()
        }

        private fun requestLocationPermissions() {
          if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION), foregroundLocationPermissionsRequestCode)
          }
        }

      }
      ```

      ```react React Native theme={null}
      import React, { useState, useEffect } from "react";
      import Radar from "react-native-radar";

      export default function App() {
        Radar.initialize("prj_live_pk_...");

        useEffect(() => {
          Radar.setUserId("foo")
        }, [userId]);

        let permissionStatus = await Radar.getPermissionStatus().then((permissionStatus)) 

        return (
          <div id="content">
          </div>
        );
      }
      ```
    </CodeGroup>

    Learn about platform-specific permissions in the [iOS SDK documentation](/sdk/ios) and [Android SDK documentation](/sdk/android).
  </Step>

  <Step title="Configure remote tracking options">
    In the Radar dashboard, navigate to the SDK configuration section in [settings](https://dashboard.radar.com/settings#sdk-configuration). 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:

    <CodeGroup>
      ```json iOS theme={null}
      {
      "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
      }
      ```

      ```json Android theme={null}
      {
      "desiredStoppedUpdateInterval": 3,
      "fastestStoppedUpdateInterval": 3,
      "desiredMovingUpdateInterval": 3,
      "fastestMovingUpdateInterval": 3,
      "desiredSyncInterval": 2,
      "desiredAccuracy": 2,
      "stopDuration": 140,
      "stopDistance": 70,
      "replay": 1,
      "sync": 2,
      "useStoppedGeofence": true,
      "stoppedGeofenceRadius": 100,
      "useMovingGeofence": true,
      "movingGeofenceRadius": 100,
      "syncGeofences": true,
      "syncGeofencesLimit": 10,
      "beacons": false,
      "foregroundServiceEnabled": true
      }

      ```
    </CodeGroup>

    In the field entitled "Geofence tags", input the tag of the geofence you created to trigger the increase in tracking frequency, `ramp-up`.
  </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`.

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

      ```kotlin Kotlin theme={null}
      let tripOptions = RadarTripOptions("456")
      tripOptions.destinationGeofenceTag = "restaurant"
      tripOptions.destinationGeofenceExternalId = "123" 
      tripOptions.mode = RadarRouteMode.CAR
      Radar.startTrip(tripOptions)
      ```

      ```react React Native theme={null}
      const tripOptions = {
        externalId: "456",
        destinationGeofenceTag: "restaurant",
        destinationGeofenceExternalId: "123",
        mode: "car"
      };
      Radar.startTrip(tripOptions);
      ```
    </CodeGroup>

    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.
  </Step>
</Steps>
