Cheetah CES Docs Portal

Navigation
Home
GitHub
Email
Corporate Site


Places Kit

« Back to iOS Kit References

This kit supports the following:

  • Device authorization for location-related features
  • Fetching and handling device’s current location
  • Geofencing
  • Handling of Geofence Events

Configuration

This documentation assumes that necessary setup like setting capabilities, providing usage texts in Info.plist is already done.

Geofencing

To enable Geofencing, make sure the GEOFENCING_ENABLED configuration in the CheetahDigitalInfo.plist is set to TRUE

Localization

Add the following strings in your application’s Localizable.strings.

"Geofence.ClientEvent.Enter"
"Geofence.ClientEvent.Exit"
"Geofence.ClientEvent.MultipleOffersFound"
"Geofence.ClientEvent.SingleOfferFound"

Usage

var locationEventListener: NSObjectProtocol?
locationEventListener = NotificationCenter.default.addObserver(forName: .locationManagerEvents, object: nil,  queue: .main, using: { [weak self] notification in
	// TODO: Handle notification.userInfo as LocationManager.Event
})

Authorization

Call the following method to check authorization and request if needed.

LocationManager.shared.checkAndRequestAuthorizationIfNeeded()

This will trigger a LocationManager.Event.userDidGrantLocationPermission event that should be handled by your locationEventListener

Getting the device’s current location

After requesting authorization that resulted with a granted permission, the following method should be called to fetch the current location.

LocationManager.shared.startReceivingLocationUpdates()

This will trigger either a LocationManager.Event.didSetCurrentLocation or a LocationManager.Event.didFailUpdatingLocation which should be handled by your locationEventListener.

Geofencing

Call the followings method to start/stop monitoring region depending on the device’s current location.

  • GeofenceManager.shared.start() - To start fetching current location and monitoring regions
  • GeofenceManager.shared.stop() - To stop receiving location updates
  • GeofenceManager.shared.stopMonitoringAllRegions() - To stop monitoring regions

Components

Constants

LocationManager.Event

An enumaration with associated values for location-related events.

  • didSetCurrentLocation - Event for when the device’s current location was fetched and set
  • didFailUpdatingLocation - Event for when fetching the device’s current location failed
  • userDidGrantLocationPermission - Event for when the user did or did not grant the application to use location services
  • unknownAuthorizationStatusReceived - Event for an unhandled authorization status was returned

GeofenceClientEvents

A protocol for handling geofence-related offers (also called “client events”).

  • createClientEventRegions
  • triggerClientEvent
  • sendLocalNotification

LocationManager

A singleton object that is responsible for handling location-related data and events.

GeofenceManager

A singleton object that is responsible for handling geofence related data and events

GeofenceClientEventsManager

A class that conforms to GeofenceClientEvents protocol that serves as a the default handler for geofence events


Customization

If the provided default implementations do not satisfy your application’s requirements, you can do the following:

  • Subclass LocationManager
  • Subclass GeofenceManager
  • Subclass GeofenceClientEventsManager
  • Create a new class that conforms to GeofenceClientEvents