Skip to content

Iterate

msingleton edited this page Jul 16, 2020 · 18 revisions

Iterate

The Iterate class is the primary class of the SDK, the main entry point is the shared singleton property

public final class Iterate

Initializers

init(storage:)

Initializer

init(storage: StorageEngine = Storage.shared)

Parameters

  • storage: - storage: Storage engine to use

Properties

shared

The shared singleton instance is the primary entrypoint into the Iterate iOS SDK. Unless you have uncommon needs you should use this singleton to call methods on the Iterate class.

let shared

PreviewParameter

Query parameter used to set the preview mode

let PreviewParameter

Version

let Version

DefaultAPIHost

Default API host

let DefaultAPIHost

urlScheme

URL Scheme of the app, used for previewing surveys

var urlScheme

api

API Client, which will be initialized when the API key is

var api: APIClient?

apiHost

Optional API host override to use when creating the API client

var apiHost: String?

previewingSurveyId

The id of the survey being previewed

var previewingSurveyId: String?

storage

Storage engine for storing user data like their API key and user attributes

var storage: StorageEngine

container

Container manages the overlay window

let container

bundle

var bundle: Bundle?

companyApiKey

You Iterate API Key, you can get this from your settings page

var companyApiKey: String?

userApiKey

The API key for a user, this is returned by the server the first time a request is made by a new user

var userApiKey: String?

userProperties

var userProperties: UserProperties?

responseProperties

var responseProperties: ResponseProperties?

Methods

sendEvent(name:complete:)

Send event to determine if a survey should be shown

public func sendEvent(name: String, complete: ((Survey?, Error?) -> Void)? = nil)

Parameters

  • name: - name: Event name
  • complete: - complete: optional callback with the results of the request

configure(apiKey:apiHost:)

Configure sets the necessary configuration properties. This should be called before any other methods.

public func configure(apiKey: String, apiHost: String? = Iterate.DefaultAPIHost)

Parameters

  • apiKey: - apiKey: Your Iterate API Key, you can find this on your settings page

preview(url:)

Preview processes the custom scheme url that was used to open the app and sets the preview mode to the surveyId passed in

public func preview(url: URL)

Parameters

  • url: - url: The URL that opened the application

preview(surveyId:)

Preview a specific survey using it's id

public func preview(surveyId: String)

Parameters

  • surveyId: - surveyId: The id of the survey to preview

identify(userProperties:)

public func identify(userProperties: UserProperties?)

identify(responseProperties:)

public func identify(responseProperties: ResponseProperties?)

embedRequest(context:complete:)

Helper method used when calling the embed endpoint which is responsible for updating the user API key if a new one is returned

private func embedRequest(context: EmbedContext, complete: @escaping (EmbedResponse?, Error?) -> Void)

Parameters

  • context: - context: Embed context data
  • complete: - complete: Callback returning the response and error from the embed endpoint

updateApiKey()

Update the API client to use the latest API key. We prefer to use the user API key and fall back to the company key

private func updateApiKey()
Clone this wiki locally