Initialize the Pulsate SDK in your AppDelegate and access the manager anywhere in your app.
This page explains how to initialize and run the Pulsate SDK. Complete the installation guide first.
Before you begin
You need your App ID and App Key from the Pulsate web panel. Open your app in the panel and click the CONFIGURE icon to find them.
1. Initialize the SDK
The SDK uses a factory to create a singleton manager instance. Initialize it in your AppDelegate's application(_:didFinishLaunchingWithOptions:) method, and pass along the launchOptions dictionary.
import PULPulsate
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
do {
let authData = try PULAuthorizationData(
withAppId: "YOUR_SDK_APP_ID",
andAppKey: "YOUR_SDK_APP_KEY")
let pulsateManager = try PULPulsateFactory.getInstance(
withAuthorizationData: authData,
withLaunchOptions: launchOptions)
pulsateManager.startPulsateSession { success, error in
if let error = error {
print("Pulsate session failed: \(error)")
}
}
} catch {
print("Pulsate initialization failed: \(error)")
}
return true
}
}
Both PULAuthorizationData(withAppId:andAppKey:) and PULPulsateFactory.getInstance(...) are throwing initializers, so wrap them in a do { … } catch { … } block. PULAuthorizationData validates that the App ID and App Key are non-nil and 64 characters long, and throws otherwise.
Initialize in
didFinishLaunchingWithOptionsiOS uses CoreLocation to wake terminated apps so they can react to geofences. For that to work, you must initialize the SDK in
application(_:didFinishLaunchingWithOptions:)and pass thelaunchOptionsdictionary to Pulsate.
Reading configuration from Info.plist
As an alternative to passing keys in code, you can store your App ID and App Key under a Pulsate dictionary in your Info.plist and use the plist-based initializer:
let pulsateManager = try PULPulsateFactory.getInstance(
withLaunchOptions: launchOptions)
Controlling the app and notification delegates
By default, Pulsate takes ownership of your app's UIApplicationDelegate and UNUserNotificationCenterDelegate so it can handle push and lifecycle events for you. To keep your own delegates and forward events manually, use the full initializer:
let pulsateManager = try PULPulsateFactory.getInstance(
withAuthorizationData: authData,
withLaunchOptions: launchOptions,
withPulsateAppDelegate: false,
andPulsateNotificationDelegate: false)
If you opt out, you must forward the relevant UIApplicationDelegate and UNUserNotificationCenterDelegate callbacks to the proxy returned by pulsateManager.getPulsateSystemManager().
2. Access the manager later
After the manager is created, retrieve it anywhere in your app with getDefaultInstance(). It returns nil if no instance has been created yet.
let pulsateManager = PULPulsateFactory.getDefaultInstance()
Don't replace the app delegate after init
When Pulsate owns the app delegate, it forwards all
UIApplicationDelegatecallbacks to your original delegate. Avoid changing theUIApplicationdelegate after Pulsate is initialized.
Next steps
Continue to Managing Pulsate Sessions.

