Skip to content

Feed Authorization

If your app has a login, you usually don’t want logged-out users opening the Pulsate Feed from a push notification. Feed Authorization blocks the Feed until the user is authorized, and can replay the blocked action after login.

The simple way: userHasLoggedIn / userHasLoggedOut

Section titled “The simple way: userHasLoggedIn / userHasLoggedOut”

These two convenience methods bundle everything most apps need:

val pulsateManager = PulsateFactory.getInstance()
// After a successful login:
pulsateManager.userHasLoggedIn()
// → enables in-app messages, shows the last bounced in-app,
// marks the user authorized, replays the last blocked inbox action
// When the user logs out (or your app locks itself):
pulsateManager.userHasLoggedOut()
// → disables in-app messages, marks the user unauthorized

See Example Integration for these in a full login flow. The rest of this page covers the fine-grained methods underneath.

pulsateManager.setUserAuthorized(true) // user may open the Feed
pulsateManager.setUserAuthorized(false) // Feed blocked

Users are authorized by default. Unauthorized users cannot reach the Feed at all — not via showFeed, not from a push, not from an in-app message.

Check the current state:

pulsateManager.isUserAuthorized(object : IPulsateValueListener<Boolean> {
override fun onSuccess(value: Boolean) { /* ... */ }
override fun onError(e: Throwable) { }
})

When an unauthorized user tries to open the Feed (from a push, an in-app, or showFeed), the SDK notifies your listener — typically you navigate to your login screen. Set it once in your Application class:

class MyApp : Application() {
override fun onCreate() {
super.onCreate()
PulsateFactory.getInstance().setUserUnauthorizedListener(
object : IPulsateUserUnauthorizedListener {
override fun onUnauthorizedAction() {
// e.g. bring up your login screen
}
},
)
}
}

The SDK remembers the last blocked inbox destination. After authorizing the user, send them where they originally wanted to go:

loginSucceeded {
pulsateManager.setUserAuthorized(true)
pulsateManager.showLastUnauthorizedMessage()
}