Skip to content

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.

ToolUse it when
pause / resumeYou know the stretch of time in advance.
Display guardThe answer depends on the app’s state at the moment the survey is about to appear, or on which survey it is.
closeSurveyA survey is already on screen and has to go.

pause stops surveys started by triggers. resume turns them back on.

func checkoutDidStart() {
Responsly.shared.pause()
}
func checkoutDidFinish() {
Responsly.shared.resume()
}

While paused:

  • A trigger that matches reports paused to surveyNotShown. It is not replayed after resume.
  • 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 closeSurvey to remove it.
  • showSurvey still 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.

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.

Rules:

  • The guard is asked for surveys started by triggers and by showSurvey. It is not asked when showSurvey is called with force.
  • 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 (nil in Swift) removes it.
  • A vetoed survey reports vetoed to surveyNotShown. 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)
}
}

closeSurvey closes the survey that is on screen, or cancels one that is waiting for its delay or still loading.

Responsly.shared.closeSurvey()
  • A visible survey that is not completed counts as dismissed: surveyDismissed fires 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.

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.