Create Story

The SDK offers developers a suite of functions to craft stories available in two distinct types: Image and Video.

  • Image: An Image story facilitates the use of an image file of up to 1GB,

  • Video: A video story accommodates video files sized up to 2GB with a maximum duration of 90 seconds. The duration setting is adjustable at the network level, providing flexibility in configuration.

Each story creation offers optional StoryItems. The first supported item type, HyperLink, enables inclusion of a URL and an alias, augmenting the story with additional content for user interaction. This feature allows seamless navigation to specified destinations upon story viewing. It's important to note that the provided URL undergoes validation by the system against a predefined whitelist, configurable at the network level.

To initiate story creation, the first step involves selecting the target type. Currently, the supported targetType is 'community,' necessitating the specification of a communityId for story creation within a specific community.

The Amity SDK utilizes optimistic story creation behavior, resulting in three possible sync states: 'SYNCING,' 'SYNCED,' and 'FAILED.'

'SYNCING': Assigned to a locally created story during file uploads. 'SYNCED': Designated for stories successfully created on the server. 'FAILED': Applied when a story creation fails on the server.

The sync state value is accessible as a property of the story model.

Create Image Story

The SDK provides the 'createImageStory()' function, allowing users to create a story with an image on the specified target.

This function requires three parameters: targetType, targetId, and imageFile.

Here's an explanation of the function parameters:

  • targetType: Represents the type of target, currently supporting 'community.'

  • targetId: Corresponds to the ID of the designated target.

  • imageFile: Denotes the image file intended to be attached to the story.

  • storyItems: Additional information that can accompany the story, currently supporting a URL and its alias.

  • imageDisplayMode: Dictates how the image should be displayed on the user interface. Either FIT or FILL.

  • metadata: Provides support for additional properties, facilitating the use of custom fields.

Create Video Story

The SDK provides the 'createVideoStory()' function, allowing users to create a story with a video on the specified target.

This function requires three parameters: targetType, targetId, and videoFile.

Here's an explanation of the function parameters:

  • targetType: Represents the type of target, currently supporting 'community.'

  • targetId: Corresponds to the ID of the designated target.

  • videoFile: Denotes the video file intended to be attached to the story.

  • storyItems: Additional information that can accompany the story, currently supporting a URL and its alias.

  • metadata: Provides support for additional properties, facilitating the use of custom fields.

Last updated