Skip to content

User & Inbox Authorization

Pulsate does not use auth tokens or a separate inbox login. Identity is established with an alias (see Session management via startPulsateSession(forAlias:)), and authorization is a simple boolean gate: you tell the SDK whether the current user is allowed to see gated content. While a user is unauthorized, Pulsate blocks messages and cards that would otherwise open — for example, a user tapping a notification cannot enter the feed until you authorize them.

By default every user is authorized. Flip the flag to false when a user signs out (or before they complete your login flow) and back to true once they authenticate.

Use setUserAuthorized(_:) to tell the SDK whether the current user may see gated content, and isUserAuthorized() to read the current value.

import PULPulsate
let manager = PULPulsateFactory.getDefaultInstance()
// User failed / has not completed your login flow
manager?.setUserAuthorized(false)
// User successfully authenticated
manager?.setUserAuthorized(true)
let authorized = manager?.isUserAuthorized() ?? false

userHasLoggedIn() and userHasLoggedOut() bundle the common transitions so you don’t have to toggle several settings by hand.

  • userHasLoggedIn() — authorizes the user and shows any in-app / unauthorized content that was queued while they were signed out.
  • userHasLoggedOut() — de-authorizes the user and disables in-app notifications.
let manager = PULPulsateFactory.getDefaultInstance()
// Call after your app confirms a successful sign-in
manager?.userHasLoggedIn()
// Call when the user signs out
manager?.userHasLoggedOut()

When an unauthorized user performs an action that would open gated content, Pulsate reports it through PULPulsateUnauthorizedManagerDelegate so you can start your own sign-in flow.

Unauthorized user actions include:

  1. Entering the app by tapping a card notification.
  2. Entering the app by tapping a message notification.

Adopt the protocol and assign the delegate:

import UIKit
import PULPulsate
@main
class AppDelegate: UIResponder, UIApplicationDelegate, PULPulsateUnauthorizedManagerDelegate {
var window: UIWindow?
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
do {
let authData = try PULAuthorizationData(withAppId: "APP_ID", andAppKey: "APP_KEY")
let manager = try PULPulsateFactory.getInstance(
withAuthorizationData: authData,
withLaunchOptions: launchOptions
)
manager.unauthorizedDelegate = self
} catch {
print("Pulsate init failed: \(error)")
}
return true
}
// Called whenever an unauthorized user triggers a gated action
func unauthorizedAction(_ action: String) {
// Present your login / PIN flow, then call setUserAuthorized(true)
}
}

After you authorize a user, showLastUnauthorizedMessage() re-opens the card or message that was blocked while they were unauthorized. Use removeUnauthorizedMessage() instead if you want to discard the pending item rather than show it.

let manager = PULPulsateFactory.getDefaultInstance()
manager?.setUserAuthorized(true)
// Redirect the user to the card/message that was blocked
manager?.showLastUnauthorizedMessage()
// …or discard it
// manager?.removeUnauthorizedMessage()

5. Enabling / disabling in-app notifications

Section titled “5. Enabling / disabling in-app notifications”

In-app notifications are a separate control from the authorization flag. Use enable(inAppNotification:) to turn them on or off — for example, to hide in-app content from signed-out users.

let manager = PULPulsateFactory.getDefaultInstance()
manager?.enable(inAppNotification: false) // hide in-app notifications
manager?.enable(inAppNotification: true) // show in-app notifications
let enabled = manager?.isInAppNotificationEnabled() ?? false

When in-app notifications are disabled, the most recent one is held by the SDK. Once you re-enable them, showLastInAppNotification(_:) displays the last blocked in-app notification.

let manager = PULPulsateFactory.getDefaultInstance()
manager?.enable(inAppNotification: true)
manager?.showLastInAppNotification() // or pass true to force display