Hooks
Hooks let your app decide how to react to Screeb lifecycle events, or whether a survey/message is allowed to display.
KMP hooks are supported on Android and iOS for:
initSdkstartSurveystartMessage
Register hooksโ
import app.screeb.sdk.kmp.ScreebHooks
val hooks = ScreebHooks(
version = "1.0.0",
callbacks = mapOf(
"onSurveyDisplayAllowed" to { payload ->
println("Display decision payload: $payload")
true
},
"onSurveyShowed" to { payload ->
println("Survey shown: $payload")
null
},
),
)
Screeb.initSdk(
channelId = "<YOUR_CHANNEL_ID>",
hooks = hooks,
)
The callback receives the native Screeb hook payload as a JSON string.
Return a hook resultโ
Return true or false from decision hooks such as onSurveyDisplayAllowed.
"onSurveyDisplayAllowed" to { payload ->
val canDisplay = isUserAllowedToSeeSurvey()
canDisplay
}
Return null when the hook does not need to send a decision back to Screeb.
Start a survey with hooksโ
Screeb.startSurvey(
surveyId = "<SURVEY_ID>",
hooks = hooks,
)
Start a message with hooksโ
Screeb.startMessage(
messageId = "<MESSAGE_ID>",
hooks = hooks,
)