Skip to content

Latest commit

 

History

History
93 lines (70 loc) · 3.51 KB

File metadata and controls

93 lines (70 loc) · 3.51 KB

Setup for WakeUp Sample (Obj-C)

  1. 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.

  2. Make sure you are using the latest version of Xcode (16.0 or newer) and targeting iOS 14.0 or higher.

  3. 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.

    Screenshot1

  4. 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.

    Screenshot2

  5. 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;
    }
  6. Import the PSLocation framework headers in your AppDelegate.h file:

    #import <PSLocation/PSLocation.h>

App Details to Note

  1. 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];
    }
  2. In ViewController, the method startLocationManager calls
    startMonitoringDeparture
    on the PSLocationManager:

    - (void)startLocationManager
    {
        if (_locationManager == nil) {
            ...
            [_locationManager startMonitoringDeparture];
        }
    }
  3. 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)];
    }
  4. 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