Skip to Content

Events

let registration = OneSygnal.shared.on("survey:shown") { data in let surveyId = data as? String print(surveyId ?? "") } // unsubscribe: registration.cancel()

on() returns a Registration; call .cancel() to stop receiving that event. Double-cancel is a no-op. There is no off(event, callback) on iOS — Registration is the only unsubscribe mechanism (Swift closures aren’t Equatable, so there’s nothing to match by reference the way web’s off() does).

Event names and payloads

EventPayload (data as? …)Notes
readynilFires once initialize() has fully settled successfully — the same moment its completion resolves true. A listener registered after ready already fired still receives it immediately (a replay latch on readyEmitted).
survey:shownString — the survey IDFires once the survey overlay’s UIWindow is confirmed attached. Not an object — cast with data as? String, not data as? [String: Any].
survey:completedString — the survey IDFires once a survey is fully completed.
survey:dismissedString — the survey IDFires when a survey is dismissed without completion — including the fail-closed path for an unsupported question type.
survey:question_answered[String: Any] with surveyId: String, questionId: StringFires once per answered question. This is iOS/Android’s name; web’s equivalent is survey:step, with a different payload shape (adds a step index) — there is no survey:step on iOS.

survey:shown/survey:completed/survey:dismissed payloads are a bare String, not an object — verified directly against emit("survey:shown", survey.id) etc. in Api/OneSygnal.swift. Web’s equivalent payloads are objects ({ surveyId }). Don’t assume the shape is the same across platforms if you’re sharing analytics-forwarding code between web and native.

What’s absent on iOS

There is no survey:step on iOS — that’s web’s name for what iOS calls survey:question_answered, with a wider payload (step index included). One name/payload should probably win eventually, but renaming either breaks existing integrators of that platform, so both are documented as-is. See Platform Parity.