-
Obtain a PathSense SDK Client ID and API Key by contacting PathSense.
The legacy “GET STARTED” portal is no longer active. SDK credentials are issued privately.
-
Make sure you are using the latest version of Xcode (16.0 or newer) and targeting iOS 14.0 or higher.
-
Add the PSLocation.xcframework (or PSLocation.framework) to your Xcode project.
This framework must also be added to Embedded Binaries / Frameworks, Libraries and Embedded Content, and set to Embed & Sign. -
Under the Build Phases tab in your target, click ➕ and select New Run Script Phase.
Configure it as shown below, ensuring this phase appears below Embed Frameworks. -
In your AppDelegate, add the following code to
application:didFinishLaunchingWithOptions::- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [PSLocation setApiKey:@"YOUR_API_KEY" andClientID:@"YOUR_CLIENT_ID"]; return YES; }
-
Import the PSLocation framework headers in your AppDelegate.h file:
#import <PSLocation/PSLocation.h>
-
In application:didFinishLaunchingWithOptions: we check launchOptions to determine whether the app is being woken up by iOS:
if ([launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey]) { ViewController *vc = (ViewController *)[[self window] rootViewController]; [vc startLocationManager]; }
-
In ViewController, the method startLocationManager calls
startMonitoringDeparture
on the PSLocationManager:- (void)startLocationManager { if (_locationManager == nil) { ... [_locationManager startMonitoringDeparture]; } }
-
From handleButton: we set a location to monitor for departure by calling
setDepartureCoordinate:- (void)handleButton:(id)sender { #warning Set the location you want to monitor departures for here [_locationManager setDepartureCoordinate:CLLocationCoordinate2DMake(33.02280304, -117.28318958)]; }
-
The PSLocationManagerDelegate provides callbacks when the departure location changes or a departure occurs:
- (void)psLocationManager:(PSLocationManager *)manager didUpdateDepartureCoordinate:(CLLocationCoordinate2D)coordinate { // Called whenever setDepartureCoordinate is invoked } - (void)psLocationManager:(PSLocationManager *)manager didDepartCoordinate:(CLLocationCoordinate2D)coordinate { // Called when a departure is detected. // The coordinate is the one previously passed to setDepartureCoordinate. }
SDK Version: 1.5.1 Xcode: 16 iOS Target: 14 or later
© PathSense Inc. — Updated for SDK 1.5.1 / Xcode 16 / iOS 18

