Skip to main content
Version: 2.5.x

Implementing the listener

The JOIN Stories SDK exposes a listener, JoinStoriesListener, with 4 optional methods:

  • onStoryPlayerOnlyLoaded: only use in player standalone mode. It allows you to control the player appereance and display a loader for example
  • onStoryPlayerOnlyDismissed: only use in player standalone mode. It is called when the player is dismissed, being with a swipe down, a tap on the cross at the top left (when activated) or a tap at the beginning of the first story / end of the last story.
  • onStoryFetchError: will be called whenever a problem occurs and stories aren't fetched
  • onStoryFetchEmpty: will be call when the fetch query returns successfully, but contains no story
  • onStoryFetchSuccess: will be call when the fetch query returns successfully
interface JoinStoriesListener {
fun onStoryPlayerOnlyLoaded() {}
fun onStoryPlayerOnlyDismissed(state: OnDismissState) {}
fun onStoryFetchError(e: StoryException) {}
fun onStoryFetchEmpty() {}
fun onStoryFetchSuccess() {}
fun onStoryLinkClick(link: String) {}
}

state: OnDismissState has two possible states:

  • OnDismissManual : triggered when the cross is clicked or swiped down. Default value
  • OnDismissAuto : triggered when the story is finished or when you go back to the first story

e: StoryException has two parameters:

  • message : return error message of the exception
  • errorCode : return error code of http request

Implementing the listener is optional and not doing it won't affect the SDK behavior.