Skip to content

API reference

The API is the same on every platform, written in each platform’s idiom. The native iOS and Android SDKs implement the behaviour. React Native, Flutter and Unity forward to them and add a few helpers of their own.

  • Every call is fire-and-forget: it returns immediately and reports results through events.
  • Every call is safe from any thread.
  • Every call is safe before initialize. It is remembered and applied when the SDK starts. The exception is showSurvey, which reports not_initialized.
  • Listener callbacks and the display guard run on the main (UI) thread.
  • Trait and property values are strings, numbers, booleans or dates. A null value removes a trait.
CallBehaviour
initialize(sdkKey, options)Starts the SDK: loads the cached configuration, downloads a new one when needed and applies the calls made so far. Options: apiHost, logLevel. Idempotent for the same key. A different key resets the local state first.
identify(userId, traits)Sets the user ID and merges the traits into the stored ones. Saved on the device.
setAttributes(traits)Merges traits without changing the user ID. A null value removes a trait.
track(event, properties)Adds one to the event’s count and evaluates event triggers.
screen(name)Sets the current screen and evaluates screen triggers.
showSurvey(surveyId, options)Shows a survey by its Survey ID. Options: force, hiddenFields, locale, presentation. Audience, schedule and frequency apply unless force is set.
closeSurvey()Closes the visible survey; it counts as dismissed unless it was completed. A survey that is still waiting or loading is cancelled without a callback, because it was never shown.
pause()Stops surveys started by triggers. showSurvey still works. Kept in memory only.
resume()Resumes surveys started by triggers.
setLocale(tag)Overrides the language for surveys and for the languages audience rule. null returns to the device language. Saved on the device.
setHiddenFields(map)Sets hidden-field values sent with every survey. Replaces the previous map. Saved on the device.
setTrackingEnabled(enabled)false switches the SDK off: no network, no targeting, nothing shown. Saved on the device and kept by reset.
reset()Clears the user ID, traits, language override, hidden fields, event counts, display history and cached configuration. Closes a visible survey. Keeps the install ID and the tracking setting. The SDK stays initialized.
setDisplayGuard(guard)Sets a function that is asked before a survey becomes visible and can veto it. No answer within 2 seconds counts as allow. Not asked for force. null removes it.
addListener(listener)Registers callbacks for the six events.
removeListener(…)Removes a listener.

Guides: identify, track and screen, showSurvey, pause, display guard, closeSurvey, listeners, hidden fields, setLocale, setTrackingEnabled and reset.

Swift, module ResponslySDK. All calls go through Responsly.shared.

import ResponslySDK
Responsly.shared.initialize(sdkKey: "rsk_…", options: ResponslyOptions(apiHost: URL(string: "https://api.responsly.com")!, logLevel: .debug))
Responsly.shared.identify(userId: "user-123", traits: ["plan": "pro", "seats": 5, "beta": true, "signed_up": .date(Date())])
Responsly.shared.setAttributes(["plan": "team", "beta": nil])
Responsly.shared.track("purchase_completed", properties: ["value": 49.9])
Responsly.shared.screen("Checkout")
Responsly.shared.showSurvey("AbCd1234", options: ResponslyShowOptions(force: false, hiddenFields: ["order_id": "A-77"], locale: "pl", presentation: .dialog))
Responsly.shared.closeSurvey()
Responsly.shared.pause()
Responsly.shared.resume()
Responsly.shared.setLocale("pl") // nil = device language
Responsly.shared.setHiddenFields(["order_id": "A-77"])
Responsly.shared.setTrackingEnabled(false)
Responsly.shared.reset()
Responsly.shared.setDisplayGuard { survey, decide in decide(!checkoutInProgress) }
let token = Responsly.shared.addListener(MyListener()) // ResponslyListener protocol, all methods optional
Responsly.shared.removeListener(token)
Responsly.sdkVersion

ResponslyListener methods:

func surveyShown(_ event: ResponslySurveyShownEvent)
func surveyNotShown(_ event: ResponslySurveyNotShownEvent)
func questionAnswered(_ event: ResponslyQuestionAnsweredEvent)
func surveyCompleted(_ event: ResponslySurveyCompletedEvent)
func surveyDismissed(_ event: ResponslySurveyDismissedEvent)
func surveyError(_ event: ResponslySurveyErrorEvent)

ResponslyListenerBlock is the closure-based variant. Every event has toDictionary(), which returns its fields with snake_case keys.

Swift specifics:

  • options can be left out of initialize and showSurvey, traits out of identify and properties out of track. ResponslyOptions and ResponslyShowOptions have a default for every field; the default log level is .error.
  • Trait and property values are ResponslyValue: .string, .number, .bool, .date. String, number and boolean literals convert automatically. ResponslyValue.from(_:), ResponslyValue.traits(from:) and ResponslyValue.properties(from:) convert loosely typed values.
  • reason is a ResponslyNotShownReason, trigger.type a ResponslyTriggerType and presentation a ResponslyPresentationStyle. The rawValue of each is the string listed on this page. trigger.name is optional.
  • An answer’s value is Any: String, NSNumber, an array, a dictionary or NSNull.
  • addListener returns a ResponslyListenerToken. The SDK keeps the listener until removeListener(token).

All events are delivered on the main thread. Field names are shown in camelCase; Unity uses PascalCase (e.SurveyId), and toDictionary() / toMap() on iOS and Android use snake_case keys (survey_id).

EventFires whenFields
surveyShownThe survey became visible.survey.id, survey.name, trigger.type, trigger.name
surveyNotShownA survey matched a trigger or was requested with showSurvey, but was not shown.surveyId, reason
questionAnsweredThe respondent answered a question.surveyId, questionId, type, title, value
surveyCompletedThe respondent submitted the survey.surveyId, responseId, answers[] (questionId, type, title, value)
surveyDismissedThe survey was closed before it was completed.surveyId
surveyErrorThe survey reported an error while it was visible.surveyId, code, message

Names per platform:

EventiOSAndroid, React NativeFlutter, Unity
ShownsurveyShownonSurveyShownSurveyShown
Not shownsurveyNotShownonSurveyNotShownSurveyNotShown
Question answeredquestionAnsweredonQuestionAnsweredQuestionAnswered
CompletedsurveyCompletedonSurveyCompletedSurveyCompleted
DismissedsurveyDismissedonSurveyDismissedSurveyDismissed
ErrorsurveyErroronSurveyErrorSurveyError

On iOS, Android and React Native these are listener methods. In Flutter they are the event classes of Responsly.events, and in Unity they are C# events on ResponslySDK.

Field details and the order of events are in Callbacks.

FieldTypeDescription
apiHostURL (URL in Swift, a string elsewhere)Base address of the Responsly API. Defaults to https://api.responsly.com. Change it only when Responsly support tells you to.
logLevelLog levelHow much the SDK logs.

The type is ResponslyOptions on iOS, Android, Flutter and Unity, and a plain object in React Native.

FieldTypeDescription
forceboolean, default falseSkip audience, schedule, frequency and the display guard.
hiddenFieldsmap of string to stringHidden-field values for this survey only. Combined with the setHiddenFields map; the per-call value wins for a key present in both.
localelanguage tagLanguage for this survey only.
presentationPresentation styleOverrides the style set in the Mobile app tab.

The type is ResponslyShowOptions on iOS and ShowOptions on Android and Unity. React Native takes a plain object. Flutter takes them as named parameters of showSurvey.

The styles are bottom_sheet, dialog and fullscreen.

PlatformValues
iOS.bottomSheet, .dialog, .fullscreen
AndroidPresentationStyle.BOTTOM_SHEET, PresentationStyle.DIALOG, PresentationStyle.FULLSCREEN
React Native'bottom_sheet', 'dialog', 'fullscreen'
FlutterResponslyPresentation.bottomSheet, ResponslyPresentation.dialog, ResponslyPresentation.fullscreen
UnityResponslyPresentation.BottomSheet, ResponslyPresentation.Dialog, ResponslyPresentation.Fullscreen

Layouts and sizes are described in Appearance.

The levels are none, error, info and debug, from silent to everything.

PlatformValues
iOS.none, .error, .info, .debug
AndroidLogLevel.NONE, LogLevel.ERROR, LogLevel.INFO, LogLevel.DEBUG
React Native'none', 'error', 'info', 'debug'
FlutterResponslyLogLevel.none, ResponslyLogLevel.error, ResponslyLogLevel.info, ResponslyLogLevel.debug
UnityResponslyLogLevel.None, ResponslyLogLevel.Error, ResponslyLogLevel.Info, ResponslyLogLevel.Debug

What each level logs is described in Testing & debugging.

Values are strings, numbers, booleans or dates. A null value (nil in Swift) removes a trait.

PlatformStringNumberBooleanDate
iOS"pro"5, 49.9true.date(Date())
AndroidStringInt, Long, DoubleBooleanjava.util.Date
React NativestringnumberbooleanDate
FlutterStringint, doubleboolDateTime
Unitystringint, doubleboolISO 8601 UTC string

Dates are stored and compared in UTC with seconds precision, as 2026-11-10T12:00:00Z.

Passed to the display guard and included in surveyShown. The type is ResponslySurvey on iOS and Unity.

FieldDescription
idThe Survey ID.
nameThe form’s name in Responsly.

Included in surveyShown.

FieldDescription
typeevent, screen, app_launch, or manual for showSurvey.
nameThe event or screen name. null (absent on iOS) for app_launch and manual.

An item of answers in surveyCompleted. questionAnswered carries the same four fields.

FieldDescription
questionIdThe question’s ID.
typeThe question’s type, for example nps, rating, multiple_choice, text.
titleThe question text.
valueThe answer as the survey stores it: a string, number, boolean, list or map. Number scales give a number.

The reason of surveyNotShown is one of:

disabled, not_initialized, config_unavailable, survey_not_found, another_survey_visible, another_survey_selected, paused, outside_schedule, platform_mismatch, app_mismatch, locale_mismatch, audience_mismatch, already_completed, frequency_limit, recontact_wait, global_cooldown, sampled_out, screen_changed, vetoed, load_failed, survey_unavailable.

Each one is explained, with a fix, in Testing & debugging.

PlatformConstant
iOSResponsly.sdkVersion
AndroidResponsly.SDK_VERSION