Implementing StorytellerDelegate Callbacks

A StorytellerDelegate has methods for managing Storyteller events. It is used as global object for handling all events when opening a Story Player with and without the StorytellerRowView or StorytellerGridView. Please see the dedicated StorytellerListViewDelegate for handling events related to rows and grids.

How to Use

To use global StorytellerDelegate, implement the StorytellerDelegate interface by overriding the required methods and set it in Storyteller object.

  • onUserActivityOccurred(type: UserActivity.EventType, data: UserActivityData) - called when an analytics event is triggered

  • getAdsForList(stories: List<ClientStory>, onComplete: (AdResponse) -> Unit, onError: () -> Unit) - called when the tenant is configured to request ads from the containing app and the SDK requires ad data from the containing app

  • userNavigatedToApp(url: String) - called when a user taps on an action button on a Page which should direct the user to a specific place within the integrating app

  • configureWebView(webview: Webview, url : String?, favicon: Bitmap?) - called when an action button is tapped on a Page for web links and the WebView starts to load the page. This callback can be used to inject an arbitrary javascript into WebView or to change WebView settings.

    Note:

    • this action will be fired for every visited URL - even for those followed by link click
    • webview param is connected to the parent activity, so extra care should be taken when modifying its configuration. In particular activity expect to receive notifications through WebChromeClient and WebViewClient interfaces attached to the WebView

Example:

    Storyteller.storytellerDelegate = myCustomStorytellerDelegate

Analytics

The callback onUserActivityOccurred provides analytics events and corresponding data triggered internally by the SDK. This information can be used in your app.

The following parameters are passed to the callback method:

  • type - type of event that occurred, as a UserActivity.EventType enum
  • data - an object containing data about the event which occurred

Example:

    ...
    override fun onUserActivityOccurred(type: UserActivity.EventType, data: UserActivityData) {
        if (type == UserActivity.EventType.OPENED_STORY) {
            // Retrieve the story id value
            val openStoryId = data.storyId
            // Retrieve the story title value
            val openStoryTitle = data.storyTitle

            // Report retrieved values from your app
        }
    }

For a detailed discussion of all the relevant events and properties please see the dedicated Analytics page.

Client Ads

By implementing getAdsForList, you can provide custom ad data for the SDK to render, this is only applicable when the ad configuration is set to Integrating App in the CMS. Ad data can be obtained asynchronously, and should be provided using the onComplete closure parameter.

Example:

    ...
    override fun getAdsForList(stories: List<ClientStory>, onComplete: (AdResponse) -> Unit) {
        // Action to get some ads
        val ads = getMyAds()
        // Provide the ads to the SDK
        onComplete(ads)
    }

For a detailed discussion of all the relevant considerations, please see the dedicated Ads page.

Swiping Up to the Integrating App

The callback userNavigatedToApp is called when a user taps on an action button on a page which has its link type set to In App. In this case, your app will be passed a URL which has been entered in the Storyteller CMS and your app is then responsible for parsing this URL and following it to the correct location within your app.

Example:

    override fun userNavigatedToApp(url: String) {
        // parse the url and navigate to the destination
    }
PREVIOUS
Forward Arrow