Control when surveys appear
Triggers decide when a survey may appear. Your app knows when it must not: during checkout, onboarding, a video, a call, a boss fight. Three tools cover that.
| Tool | Use it when |
|---|---|
pause / resume | You know the stretch of time in advance. |
| Display guard | The answer depends on the app’s state at the moment the survey is about to appear, or on which survey it is. |
closeSurvey | A survey is already on screen and has to go. |
Pause and resume
Section titled “Pause and resume”pause stops surveys started by triggers. resume turns them back on.
func checkoutDidStart() { Responsly.shared.pause()}
func checkoutDidFinish() { Responsly.shared.resume()}fun onCheckoutStarted() { Responsly.pause()}
fun onCheckoutFinished() { Responsly.resume()}useEffect(() => { Responsly.pause() return () => Responsly.resume()}, [])@overridevoid initState() { super.initState(); Responsly.pause();}
@overridevoid dispose() { Responsly.resume(); super.dispose();}void OnLevelStarted() => ResponslySDK.Pause();
void OnLevelFinished() => ResponslySDK.Resume();While paused:
- A trigger that matches reports
pausedtosurveyNotShown. It is not replayed afterresume. - Event counts keep going up, so “from occurrence no.” stays correct.
- A survey that was waiting for its delay is dropped when the delay ends.
- A survey that is already visible stays. Use
closeSurveyto remove it. showSurveystill works. A pause blocks triggers, not your explicit calls.
The paused state is kept in memory only. After an app restart the SDK is not paused. If the app must start paused, call pause at startup; it is safe before initialize.
Display guard
Section titled “Display guard”A display guard is a function the SDK calls right before a survey would appear. Allow the survey or veto it.
Responsly.shared.setDisplayGuard { survey, decide in decide(!checkoutInProgress)}Call decide exactly once, now or a moment later.
Responsly.setDisplayGuard { survey, decision -> if (checkoutInProgress) decision.veto() else decision.allow()}Responsly.setDisplayGuard((survey) => !checkoutInProgress)Return a boolean or a Promise<boolean>.
Responsly.setDisplayGuard((survey) async => !checkoutInProgress);ResponslySDK.SetDisplayGuard(survey => !inBossFight);Rules:
- The guard is asked for surveys started by triggers and by
showSurvey. It is not asked whenshowSurveyis called withforce. - It is asked last, after targeting and after the delay. What it sees is the app’s state at the moment the survey would appear.
- It runs on the main (UI) thread.
- Answer within 2 seconds. No answer counts as allow, so a slow or broken guard cannot block surveys forever.
- There is one guard. Setting a new one replaces the old one; passing
null(nilin Swift) removes it. - A vetoed survey reports
vetoedtosurveyNotShown. It does not count as a display, so it can match again on the next trigger.
The guard receives the survey, with its ID and name, so the decision can differ per survey:
Responsly.shared.setDisplayGuard { survey, decide in if survey.id == "AbCd1234" { decide(true) // the checkout survey is allowed everywhere } else { decide(!checkoutInProgress) }}Responsly.setDisplayGuard { survey, decision -> if (survey.id == "AbCd1234" || !checkoutInProgress) decision.allow() else decision.veto()}Responsly.setDisplayGuard((survey) => survey.id === 'AbCd1234' || !checkoutInProgress)Responsly.setDisplayGuard((survey) async => survey.id == 'AbCd1234' || !checkoutInProgress);ResponslySDK.SetDisplayGuard(survey => survey.Id == "AbCd1234" || !inBossFight);Close a survey
Section titled “Close a survey”closeSurvey closes the survey that is on screen, or cancels one that is waiting for its delay or still loading.
Responsly.shared.closeSurvey()Responsly.closeSurvey()Responsly.closeSurvey()Responsly.closeSurvey();ResponslySDK.CloseSurvey();- A visible survey that is not completed counts as dismissed:
surveyDismissedfires and the form’s closed count goes up. - A survey that was still waiting or loading is cancelled. It was never displayed, so it is not counted and no callback fires.
- After completion it only removes the thank-you page early. Nothing is counted and no callback fires.
- With nothing visible or waiting, it does nothing.
- It works even when the respondent is not allowed to close the survey themselves.
Typical uses: a session timeout, an incoming call screen, navigation into a flow where a survey must not stay open. reset closes a visible survey by itself, so there is no need to call closeSurvey before it.
Switch the SDK off
Section titled “Switch the SDK off”To stop everything, including network requests, use setTrackingEnabled(false). It is meant for consent and opt-out and is saved across restarts. See Privacy & data.