Languages used
- Swift
Features used
Steps
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
2
Import geofences
On the Geofences page, create a geofence for a McRadar’s location. In this case, use
restaurant
for the geofence tag
and 123
for the geofence externalId
.3
Install the Radar iOS SDK
Install the Radar SDK using CocoaPods or Carthage (recommended) or by downloading the framework and dragging it into your project.Initialize the SDK in your
AppDelegate
class with your publishable API key, then request location permissions.4
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:5
Display live ETAs in the trip tracking dashboard
Display live ETAs on the trip tracking dashboard, available on the Enterprise plan. Or, display live ETAs in your own UI by polling the list trips API or listening for trip events sent to a webhook.
6
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.