Moments Events

Storyly Moments Events

This section shows you how to observe Storyly Moments' basic functionality events. In order to get a notification about these basic events, you should override the following function in StorylyMomentsDelegate, which you have registered in Quick Start.

func storylyMomentsEvent(event: StorylyMomentsEvent, storyGroup: MomentsStoryGroup?, stories: [MomentsStory]?) {}

📘

Tip

You can check what kind of events are sent in Storyly Moments from API docs with their explanation.

onStoryCreatorOpen Event

This event will let you know that your users intend to create a Story. isDirectMediaUpload parameter denotes whether the users intend to create a Story using application-provided media or library/camera media. In order to be notified about this event, override the following function in your delegate:

func onStoryCreatorOpen(isDirectMediaUpload: Bool)

onStoryCreatorClose Event

This event will notify you when the user closes the Story creator. In order to be notified about this event, override the following function in your delegate:

func onStoryCreatorClose()

onUserStoriesOpen Event

This event will let you know that your users intend to view their Stories. In order to be notified about this event, override the following function in your delegate:

func onUserStoriesOpen()

onUserStoriesClose Event

This event will notify you when the user closes the preview of their own Stories. In order to be notified about this event, override the following function in your delegate:

func onUserStoriesClose()

onUserActionClicked Method

This method will let you handle the CTA URL of user-generated Stories. In order to be notified about this method, override the following function in your delegate:

func onUserActionClicked(story: MomentsStory) {
        //print("Action url: \(story.url)")   
    }

onUserStoriesLoaded Event

This event will let you know that your loading of user Stories is successful. momentsStoryGroup parameter denotes loaded user Story Group information. In order to be notified about this event, override the following function in your delegate:

func onUserStoriesLoaded(momentsStoryGroup: MomentsStoryGroup?)

onUserStoriesLoadFailed Event

This event will let you know that your loading of user Stories loading is failed. errorMessage parameter denotes the failed reason for the loading. In order to be notified about this event, override the following function in your delegate:

func onUserStoriesLoadFailed(errorMessage: String)

storyHeaderClicked Event

This event will let you know that the user clicked the header icon of a Storyly Moments Story. In order to be notified about this event, override the following function in your delegate:

func storyHeaderClicked(momentsStoryGroup: MomentsStoryGroup?, story: MomentsStory?)

storyAnalyticsClicked Event

This event will let you know that the user clicked on an analytic button of a Storyly Moments Story. You can show your custom view on this callback for impressions and likes.

func storyAnalyticsClicked(momentsStory: MomentsStory?, 
                           stats: MomentsAnalytics?, 
                           analyticsType: AnalyticsType, 
                           showCustomAnalyticsView: ((UIView) -> Void))

🚧

Warning

You should set isCustomAnalyticsView to true in MomentsThemeConfig in order to use this function.

When your view is ready, you should call showCustomAnalyticsView to show your custom analytics view.

onLinkCTAPreviewURLClicked Event

This event will let you know that the user clicked the CTA Link preview on the CTA editor. You can show your custom web view on this callback.

func onLinkCTAPreviewURLClicked(url: String, showCustomLinkPreviewView: ((UIView) -> Void))

🚧

Warning

You should set isCustomPreviewView to true in MomentsThemeConfig in order to use this function.

When your view is ready, you should call showCustomLinkPreviewView to show your custom link preview.

onPreModeration Event

This event will let you pre-moderate the content before going live. With this callback, you can prevent harmful text or URL content from going live.

func onPreModeration(preModerationList: [PreModeration]?, onPreModerationCompleted: (() -> Void)?)

Below, you can find an example of usage: