InAppAutomationManager

InAppAutomationManager

Interface for controlling the behavior of In-App Automations.

Methods

getDisplayInterval() → {Promise.<number>}

Retrieves the current display interval. By default, this is 0 ms.

Returns:
Type:
Promise.<number>
Example
const displayInterval = await sdk.components.inAppAutomation.getDisplayInterval()
console.log(displayInterval)

isPaused() → {Promise.<boolean>}

Retrieves the current value of the pause state

Returns:
Type:
Promise.<boolean>
Example
const paused = await sdk.components.inAppAutomation.isPaused()
if (paused) {
  // messages display is paused
}

setCustomViewDelegate(delegate) → {Promise.<void>}

Sets a Custom View delegate which will be called to handle any custom views defined in In-App Experience views.

Note: When using a view delegate, it is recommended that you start the In-App Automation engine in "paused" mode by setting components.inAppAutomation.startInPausedState to true, and then calling setPaused(false) after you have attached your delegate. If you do not, you may miss some displays as the engine will begin processing before you have attached your delegate, causing those custom views to be empty.

Parameters:
Name Type Description
delegate InAppCustomViewDelegate

the delegate

Returns:
Type:
Promise.<void>
Example
const delegate = {
  onCustomViewShown: (name, htmlElement, properties) => {
    const view = new MyComponent(properties)
    const instance = view.render(htmlElement)
    return {
      destroy: () => instance.remove()
    }
  }
}
await sdk.components.inAppAutomation.setCustomViewDelegate(delegate)
await sdk.components.inAppAutomation.setPaused(false)

setDisplayDelegate(delegate) → {Promise.<void>}

Sets an optional display delegate which can control and be notified of in-app lifecycle events.

Note: When using a display delegate, it is recommended that you start the In-App Automation engine in "paused" mode by setting components.inAppAutomation.startInPausedState to true, and then calling setPaused(false) after you have attached your delegate. If you do not, you may miss some displays as the engine will begin processing before you have attached your delegate.

Parameters:
Name Type Description
delegate InAppDisplayDelegate

the display delegate

Returns:
Type:
Promise.<void>
Example
const delegate = {
  isMessageReadyToDisplay: (message) => {
     if (myApp.canDisplayMessage(message)) {
       return true
     }
     return false
  }
}
await sdk.components.inAppAutomation.setDisplayDelegate(delegate)
await sdk.components.inAppAutomation.setPaused(false)

setDisplayInterval(displayInterval) → {Promise.<void>}

Sets the display interval.

The display interval controls the amount of time to wait before the manager is able to display the next triggered in-app message. The default value is set to 0 ms but can be adjusted to any amount of time in ms.

Parameters:
Name Type Description
displayInterval number

the display interval in milliseconds

Returns:
Type:
Promise.<void>
Example
await sdk.components.inAppAutomation.setDisplayInterval(30000) // 30 seconds

setPaused(paused) → {Promise.<void>}

Pauses or resumes the display of in-app messaging.

This does not prevent messages from being triggered, it only pauses the display from occurring. At a later date when you unpause display, any queued messages will display as expected.

Parameters:
Name Type Description
paused

value to which the pause state should be set

Returns:
Type:
Promise.<void>
Example
// pause display of in-app experiences
await sdk.components.inAppAutomation.setPaused(true)
// resume display of in-app experiences
await sdk.components.inAppAutomation.setPaused(false)