Use this file to discover all available pages before exploring further.
In this tutorial, we show you how to use in Radar to show an on-premise mode when a user is in a geofence.
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
The tag is a group for the geofence. For example, you could set tag = venue for gaming, or tag = restaurant for restaurants. In this tutorial, we’re going to use tag = store.
Call Radar.trackOnce() to track the user’s location in the foreground. In the callback, check user.geofences to determine if the user is in a store, then change the UI to show the on-premise experience.
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() Radar.trackOnce { (status, location, events, user) in let isInStore = user?.geofences?.contains { $0.tag == "store" } if isInStore { // show on-premise mode } } return true } func requestLocationPermissions() { let status = self.locationManager.authorizationStatus if status == .notDetermined { self.locationManager.requestWhenInUseAuthorization() } }}