Skip to main content
Version: iOS SDK

Examples

Practical, task-based code snippets for the iOS SDK.

Basic setupโ€‹

Initialize Screeb once, typically in your AppDelegate or SceneDelegate (see Install):

Screeb.initSdk(
context: nil,
channelId: "<YOUR-CHANNEL-ID>"
)

If the user is already authenticated when the app starts, pass their identity directly:

Screeb.initSdk(
context: nil,
channelId: "<YOUR-CHANNEL-ID>",
identity: "user-123",
visitorProperty: [
"email": AnyEncodable("support@screeb.app"),
"plan": AnyEncodable("pro")
]
)

Track an eventโ€‹

Screeb.trackEvent(name: "Product added to cart")

Track a screenโ€‹

Screeb.trackScreen(name: "Checkout")

Start a surveyโ€‹

Screeb.startSurvey(surveyId: "<SURVEY-ID>")

Assign a groupโ€‹

Screeb.assignGroup(type: "company", name: "acme-corp")

Debug the current stateโ€‹

Screeb.debug { payload, error in print(payload ?? "") }
Screeb.debugTargeting { payload, error in print(payload ?? "") }

Reset on logoutโ€‹

Screeb.resetIdentity()
tip

Runnable reference code for these calls lives in the SDK's internal demo app, under Example/Screeb/ViewController.swift.