NeoDay iOS SDK - Survey
Handling showing Survey screens automatically or with the SurveyDelegate
The default behavior of the SDK is to show a Survey screen whenever one of the SDK's screens is currently visible. However you can implement the SurveyDelegate in order to control when a Survey screen is displayed. If you are using the Custom Event Trigger see the section When using Custom Events to trigger Survey for how to deal with Survey being displayed.
import NeoDay
class ExampleViewController: UIViewController {
func surveyExample() {
...
// Assuming the sdk is already created.
sdk.surveyDelegate = self
...
}
}
extension ExampleViewController: SurveyDelegate {
func receivedSurvey(viewController: UIViewController) {
// Display the Survey
}
}
When using Custom Events to trigger Survey
Caching Survey
Whenever Custom Event Triggers are used to trigger a Survey we advise you to handle showing the Survey yourselve by caching it first. And then to show it when its appropriate to do so within your app.
import NeoDay
class ExampleViewController: UIViewController {
func cachingSurveyExample() {
...
// Assuming the sdk is already created.
sdk.surveyDelegate = self
...
}
}
extension ExampleViewController: SurveyDelegate {
func receivedSurvey(viewController: UIViewController) {
// Cache the viewController and present it at later time inside the app.
}
}
Clearing the Survey cache
Whenever you remove the stored token from the NeoDay SDK when logging out of your app, the Survey cache will also need to be cleared. In case your user logs back in with another account while the app is still open, you don't want to accidentally show a Survey that was meant for the previous logged in user.
import NeoDay
class ExampleViewController: UIViewController {
func clearingSurveyCacheExample() {
...
// Assuming the sdk is already created.
sdk.removeToken()
// Clear the Survey cache
...
}
}