What You’ll Build
In this quickstart, you’ll:- Install and initialize the Radar SDK
- Request location permissions from the user
- Track the user’s location once (foreground tracking)
- Set up a delegate to receive events
- Start background tracking
Step 1: Installation & Setup
1
Install the SDK
First, install the Radar SDK using CocoaPods or Swift Package Manager. See the installation guide for detailed instructions.For CocoaPods, add to your Then run:
Podfile:2
Configure Info.plist
Add location permission descriptions to your
Info.plist:3
Initialize the SDK
In your
AppDelegate.swift, initialize Radar with your publishable key:Step 2: Request Location Permissions
Create a location manager to request permissions:iOS 13.4+ requires a two-step permission flow: first request “When In Use” permission, then request “Always” permission for background tracking.
Step 3: Track Location Once
Now let’s track the user’s location once (foreground tracking):Understanding the Response
ThetrackOnce completion handler receives:
status: ARadarStatusenum indicating success or failurelocation: ACLLocationobject with the user’s coordinatesevents: An array ofRadarEventobjects (geofence entries/exits, place events, etc.)user: ARadarUserobject with the current user state
View all RadarStatus values
View all RadarStatus values
.success- Location tracked successfully.errorPublishableKey- SDK not initialized.errorPermissions- Location permissions not granted.errorLocation- Location services error.errorNetwork- Network error.errorBadRequest- Invalid request parameters.errorUnauthorized- Invalid API key.errorRateLimit- Rate limit exceeded.errorServer- Server error.errorUnknown- Unknown error
Step 4: Set Up a Delegate
ImplementRadarDelegate to receive events and location updates:
AppDelegate:
Keep a strong reference to your delegate (as shown above) to ensure it receives callbacks.
Step 5: Start Background Tracking
Enable continuous background tracking with one of the preset tracking modes:Tracking Presets
Radar provides three preset tracking modes optimized for different use cases:- Responsive
- Continuous
- Efficient
- Updates every ~2.5 minutes when moving
- Shuts down when stopped to save battery
- Low battery usage
- Requires
locationbackground mode
Custom Tracking Options
You can also create custom tracking options:Step 6: Identify Users
Optionally identify users with a custom ID:If you don’t set a user ID, Radar automatically identifies users by device ID (IDFV).
Complete Example
Here’s a complete working example:Testing Your Integration
To test your integration:1
Run the app
Build and run your app on a physical device (simulator location is less accurate).
2
Grant permissions
Accept the location permission prompts when they appear.
3
Track location
Tap your “Track Once” button to send a location update to Radar.
4
View in dashboard
Open the Radar dashboard and go to the Users page to see your location update.
Next Steps
Now that you have basic tracking working, explore more features:Create Geofences
Set up geofences in the Radar dashboard
Trip Tracking
Track multi-stop trips with live ETAs
Search Places
Search for nearby places and chains
API Reference
View the complete SDK reference
Common Issues
Location permissions not granted
Location permissions not granted
Make sure you’ve added the required
NSLocationWhenInUseUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription keys to your Info.plist.On iOS 13.4+, you must request “When In Use” permission before requesting “Always” permission.Background tracking not working
Background tracking not working
Verify that:
- You’ve enabled the Location updates background mode in Signing & Capabilities
- The user granted “Always” location permission (not just “When In Use”)
- You called
Radar.startTracking()with valid tracking options
Events not received
Events not received
Make sure:
- You’ve set a delegate with
Radar.setDelegate() - You’re keeping a strong reference to your delegate object
- You’ve created geofences in the Radar dashboard
Rate limit errors
Rate limit errors
The
trackOnce() method is subject to rate limits. For continuous tracking, use startTracking() instead, which handles rate limiting automatically.Get Help
Have questions? We’re here to help!- Email: support@radar.com
- Documentation: radar.com/documentation
- Community: Radar Community