Start anonymous or identified (aliased) sessions, delay session start, and log users out.
To start a session, call either startPulsateSession (anonymous) or startPulsateSession(forAlias:) (identified). Both are described below.
Pick one and stick with it
If you start sessions with
startPulsateSession(forAlias:), always use it — don't mix the anonymous and aliased methods for starting sessions.
Once you start the first session, Pulsate automatically starts and ends sessions for you (sessions begin when the app foregrounds and end when it backgrounds). Sessions are managed automatically until you log the user out.
1. Anonymous session — startPulsateSession
startPulsateSessionAn anonymous session uses a Device GUID to identify the user on this device. Whenever the Device GUID changes, a new user is created and the old user's data can no longer be connected to the new user.
If the user has multiple devices, the same person appears as a different user per device. The Device GUID can also change if the user reinstalls the app, resets their device, or clears app data.
pulsateManager.startPulsateSession { success, error in
if let error = error {
print("Session failed: \(error)")
}
}
2. Identified session — startPulsateSession(forAlias:)
startPulsateSession(forAlias:)Deduping sets a unique identifier as the customer's alias so Pulsate recognizes the same user across multiple devices. This improves data quality by attaching multiple devices to a single profile instead of creating a separate profile per device.
Choose an alias that won't change for the user — a customer number is a good candidate. An email address is a poor choice because it can change.
Pass the unique identifier to startPulsateSession(forAlias:). An empty alias fails the listener.
pulsateManager.startPulsateSession(forAlias: uniqueIdentifier) { success, error in
if let error = error {
print("Session failed: \(error)")
}
}
3. Delaying session start
You can delay starting the session — for example, until the user logs into your app — so only logged-in users are added to Pulsate and receive content.
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)
if userLoggedIn {
pulsateManager.startPulsateSession { _, _ in }
}
} catch {
print(error)
}
return true
}
}
Still initialize on launch
Even when you delay
startPulsateSession, you must still create the manager inapplication(_:didFinishLaunchingWithOptions:). After the first session, callstartPulsateSessionon every launch where the user is logged in.
4. Logout
When a user logs out of your app, call logout to stop sending data and receiving campaigns for that user.
pulsateManager.logout { success, error in
if let error = error {
print("Logout failed: \(error)")
}
}
Logout prevents users from receiving Pulsate campaigns
After logout, the user no longer receives any Pulsate campaigns or journeys, including push notifications. Logout also prevents the SDK from sending events (such as geofence events) that could trigger a campaign or journey. If you want users to keep receiving campaigns, don't call logout.

