Quickstart
Add your key to Info.plist first (see Install):
<key>OneSygnalApiKey</key>
<string>YOUR_API_KEY</string>Then, in your app:
import OneSygnalSDK
OneSygnal.shared.initialize { success in
guard success else { return }
OneSygnal.shared.track("page_viewed")
OneSygnal.shared.identify("user_123", attributes: ["plan": "pro"])
}Or with async/await — same-name overloads exist for initialize, identify,
logout, reset, and shutdown, and Swift resolves the right one at each call site:
import OneSygnalSDK
Task {
let success = await OneSygnal.shared.initialize()
guard success else { return }
OneSygnal.shared.track("page_viewed")
_ = await OneSygnal.shared.identify("user_123", attributes: ["plan": "pro"])
}That’s it — surveys matching your active trigger rules will show automatically, rendered
in their own UIWindow above the rest of your app. No conformance is required on your
AppDelegate, SceneDelegate, or any UIViewController.
Unlike web, initialize() needs no apiUrl argument — it defaults to
https://sdk-api.1sygnal.app with zero config, and the API key comes from Info.plist
rather than a call argument. track() returns Bool synchronously (false if not yet
initialized or if surveys are disabled); identify()’s completion/async result reflects
whether the identify call actually succeeded against the backend.
If you need to know when the SDK is ready before making calls, subscribe to the ready
event — see Events. A listener registered after ready already
fired still receives it (a replay latch), so registration order relative to initialize()
doesn’t matter.