PulsateManager Methods

Swift API reference for PULPulsateManager — session, user data, attributes, events, feed, settings, badge, authorization, and location.

PULPulsateManager is the umbrella API surface for the SDK. Obtain it from the factory once the SDK is initialized:

import PULPulsate

let manager = PULPulsateFactory.getDefaultInstance()   // Optional — nil if not yet created

The sections below group the public instance API by topic. Each callback method takes a RequestListener:

public typealias RequestListener = (Bool, Error?) -> Void
public typealias Completion = () -> Void

Two enums are used by the methods below:

@objc public enum PULUserGender: Int {
    case pulMale
    case pulFemale
}

@objc public enum PULPrivacyLevel: Int {
    case pulPrivacySubscribed
    case pulPrivacyUnsubscribed
}

Delegates

/// Receives callbacks when the SDK tries to open the feed for an unauthorized user.
/// The action is blocked and you get a callback to run your own auth flow (login, PIN, etc.).
/// After authorizing, call setUserAuthorized(true), then showLastUnauthorizedMessage() to replay it.
@IBOutlet public weak var unauthorizedDelegate: PULPulsateUnauthorizedManagerDelegate?

/// Receives callbacks when the SDK changes the badge count.
@IBOutlet public weak var badgeDelegate: PULPulsateBadgeDelegate?

Session

/// Starts the Pulsate session lifecycle for an anonymous user.
/// The first session must be started by you; subsequent sessions are handled automatically.
/// Start a session from an active view controller, not from the AppDelegate.
func startPulsateSession(debugMode: Bool = false, _ listener: @escaping RequestListener)

/// Starts / switches the session for an identified user.
/// - Parameter alias: a unique identifier for this user in your system. An empty alias fails the listener.
func startPulsateSession(forAlias alias: String, debugMode: Bool = false, withListener listener: @escaping RequestListener)

/// Logs out the current user and detaches this device from the alias, clearing notifications.
/// After logout, Pulsate can no longer reach this user with campaigns. This is close to a "soft delete";
/// it is NOT a way to end a session (sessions end automatically on background).
func logout(_ listener: @escaping RequestListener)

/// Forces the user/attribute sync that normally runs when the app enters the background. Debounced.
func forceAttributeSync()

/// Triggers a user-data update pass.
func startBackgroundUpdates(_ listener: @escaping RequestListener)

/// Returns the Pulsate device GUID used to identify the user.
func getDeviceGuid() -> String?

Feed

/// Builds the Pulsate feed/inbox navigation controller for you to present however you like.
func getFeedNavigationController(completion: Completion? = nil) -> UINavigationController?

/// Dismisses a feed that was opened automatically (for example, by tapping a push notification).
func closeAutomaticallyOpenedFeed()

User profile data

All profile setters persist locally and sync when the app enters the background.

func updateFirstName(_ firstName: String?)
func updateLastName(_ lastName: String?)
func updateEmail(_ email: String?)

/// Phone number in E.164 format (validated against ^(\+)[0-9]{8,15}$), e.g. "+14085551234".
func updatePhoneNumber(_ phoneNumber: String?)
func getPhoneNumber() -> String?

func updateAge(_ age: Int)
func updateGender(_ gender: PULUserGender)

Custom attributes

Set, increment, and decrement custom attributes. Empty or nil keys/values are silently rejected.

func createAttribute(_ propertyName: String?, withString value: String?)
func createAttribute(_ propertyName: String?, withDecimal number: NSDecimalNumber?)
func createAttribute(_ propertyName: String?, withInteger number: Int)
func createAttribute(_ propertyName: String?, withBoolean boolean: Bool)
func createAttribute(_ propertyName: String?, withDate date: Date?)

func incrementIntegerAttribute(_ attributeName: String?, withInteger value: Int)
func decrementIntegerAttribute(_ attributeName: String?, withInteger value: Int)
func incrementDecimalAttribute(_ attributeName: String?, withDecimal value: NSDecimalNumber?)
func decrementDecimalAttribute(_ attributeName: String?, withDecimal value: NSDecimalNumber?)

Events

func createEvent(_ event: String?)
func createEvents(_ event: [Any]?)
func createRevenueEvent(_ revenueEvent: PULRevenueEvent?)

Deeplinks

/// Registers a handler for campaign/CTA links. Return true if your app consumed the link.
func setPULPulsateLinkListener(_ listener: @escaping PULPulsateLinkListener)
// public typealias PULPulsateLinkListener = (String) -> Bool

Push, privacy & notification settings

/// Enable/disable Pulsate push (60s debounce).
func setPushNotificationEnabled(_ enabled: Bool)
func isPushNotificationEnabled() -> Bool

/// Set subscribed/unsubscribed privacy (60s debounce).
func setPrivacy(_ privacyLevel: PULPrivacyLevel)
func getPrivacy() -> Int

/// Enable/disable geofencing (60s debounce).
func setLocationUpdatesEnabled(_ enabled: Bool)
func isLocationEnabled() -> Bool

func enable(inAppNotification enabled: Bool)
func isInAppNotificationEnabled() -> Bool

func setSmallInAppNotificationDuration(_ seconds: Int)
func getSmallInAppNotificationDuration() -> Int

/// Re-shows the last in-app notification. In-app notifications must be enabled.
func showLastInAppNotification(_ forceShow: Bool = false)

/// Toggle whether the user's initials (vs. an anonymous icon) are used for the avatar. Default: enabled.
func useInitials(forUserAvatar useInitials: Bool)
func getUseInitialsForUserAvatar() -> Bool

/// Toggle the APNS sandbox vs. production environment.
func setBuildEnvironment(isDebug enabled: Bool)

Badge & notifications

/// Requests the Pulsate badge count from the server; delivered via PULPulsateBadgeDelegate.badgeUpdated(_:).
func getBadgeCount()

/// Fetches the unread feed count via completion handler.
func getFeedUnreadCount(completion: @escaping (Int) -> Void)

/// Resets the app badge to 0 and clears delivered/pending notifications.
func clearAllNotifications()

Authorization

See User & Inbox Authorization for the full flow.

/// Marks the user authorized (default true) — controls whether gated messages are shown.
func setUserAuthorized(_ authorized: Bool)
func isUserAuthorized() -> Bool

/// Convenience: authorize + show queued in-app / unauthorized content.
func userHasLoggedIn()

/// Convenience: de-authorize + disable in-app notifications.
func userHasLoggedOut()

/// Shows the last message/card that was blocked while the user was unauthorized.
func showLastUnauthorizedMessage()

/// Clears the pending unauthorized message.
func removeUnauthorizedMessage()

Location

/// If you deferred location at init, enable it later (defers the location prompt until now).
func startLocation()

/// Swift-only. Returns the locally stored locations.
func getAllLocations() -> [PULLocation]

/// Swift-only. Clears the stored locations.
func resetStoredLocations() throws

AppDelegate proxy

/// Returns Pulsate's delegate proxy for manual AppDelegate/UNUserNotificationCenter forwarding.
/// See "AppDelegate Configuration".
func getPulsateSystemManager() -> (UIApplicationDelegate & UNUserNotificationCenterDelegate)?

Related pages