Gate Pulsate content behind your app's sign-in state using the SDK's boolean authorization flag and the unauthorized-action delegate.
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.
Note
There is no inbox token, JWT, or server-side inbox authentication in the iOS SDK. All gating described here is local and controlled entirely by the calls below.
1. Setting the authorization flag
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
Important
Opening the feed manually still works. If you present the feed yourself with
getFeedNavigationController(), it opens regardless of the authorization flag. The flag only blocks content that Pulsate opens automatically (for example, from a tapped notification). Add your own guard around manual presentation if you need to block it.
2. Login / logout convenience methods
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()
3. Reacting to unauthorized actions
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:
- Entering the app by tapping a card notification.
- 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)
}
}
4. Replaying the last blocked message
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
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
6. Showing a blocked in-app notification
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

