Skip to content

Location & Geofencing

Pulsate uses CoreLocation geofencing to trigger location-based campaigns — for example, sending an offer when a customer walks into a store’s virtual perimeter. Geofences are defined in the Pulsate CMS; the SDK registers them with iOS and reports enter/exit events.

For geofencing to work, the user must grant:

  • Precise Location, and
  • Allow Always location permission.

Your app must declare NSLocationWhenInUseUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription in its Info.plist (see Installing the iOS Pulsate SDK).

The location permission prompt is shown when you call startLocation() — not at session start. Call it at the point in your flow where you want to ask (ideally right after a priming screen; the SDK requests Always authorization):

pulsateManager.startLocation()

Use setLocationUpdatesEnabled(_:) on PULPulsateManager to opt a user in or out of Pulsate location updates. By default, all users are opted in.

import PULPulsate
guard let manager = PULPulsateFactory.getDefaultInstance() else { return }
manager.setLocationUpdatesEnabled(true) // Opt in
manager.setLocationUpdatesEnabled(false) // Opt out

Read the current preference with isLocationEnabled():

if manager.isLocationEnabled() {
// Geofencing is active for this user
}

Reading and clearing stored locations (Swift only)

Section titled “Reading and clearing stored locations (Swift only)”

For debugging or auditing, the SDK exposes the locally stored location history:

let locations: [PULLocation] = manager.getAllLocations()
try manager.resetStoredLocations() // clears the local location cache

These two methods are Swift-only (not exposed to Objective-C).

Since SDK 4.4.0, location was reworked to reduce SDK-driven location updates by more than 90% in typical use: updates are restricted when no geofence is nearby, and geofence-list refreshes wait for meaningful movement (~1 km) between refreshes. Most remaining location activity comes from the iOS Geofencing API itself.