The 'getActiveStories()
' function within the AmitySDK enables users to query non-expired stories based on a specified target, providing a LiveCollection of stories for seamless playback and browsing. Notably, the AmitySDK supports optimistic story creation, including unsynced stories within the collection. In sorting, priority is accorded to unsynced stories followed by synced ones, with secondary sorting based on the 'sortOption.' It is important to note that real-time exclusion of expired stories from LiveCollection is not supported.
This function requires two parameters: targetType, targetId.
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.
sortOption
: Specifies the secondary sorting order for stories within the collection as 'firstCreated' or 'LastCreated.' The default value is 'firstCreated,' organizing stories chronologically based on creation time.
Here's an overview of stories and how you can get started with integrating them into your application
Stories, unlike traditional posts, excel in sharing time-sensitive updates like promotions or event highlights. The SDK provides tools for creating, viewing, and interacting with diverse story content—images, videos, links—allowing configurable content duration and expiry periods. Additionally, our dashboard offers insights through basic analytics such as views, unique users, comments, reactions, and Click-Through Rate (CTR).
A Story is multi-layered. The primary content, "Data," depending on the dataType, can be either an IMAGE or a VIDEO. The secondary content, "StoryItems," complements the main content, serving as additional components. For instance, the first supported StoryItem is a Hyperlink, containing URL information and its alias. Overlaying the main content allows users to click and be redirected to the predefined destination.
The functionality of stories can be utilized through the StoryRepository
, which offers methods for interacting with a data source that stores stories. This includes methods for obtaining stories, creating a new story, and deleting a story.
Name
Data Type
Description
storyId
String
ID of the story
targetType
Enum
Type of target. COMMUNITY
targetId
String
ID of the target
dataType
Enum
Type of the story. Either IMAGE or VIDEO.
data
Object
Data of the story based on dataType
metadata
Object
Metadata of the story
storyItems
Array<StoryItem>
StoryItems of the story
syncState
Enum
Sync state of the story. [FAILED | SYNCING | SYNCED]
isDeleted
Boolean
Flag indicates whether the story is deleted.
isSeen
Boolean
Flag indicates whether the story has been viewed by the user
myReactions
Array<String>
My reactions on the story
reactionsCount
Integer
Count of reactions on the story
commentsCount
Integer
Count of comments on the story
reactions
Map<String, Integer>
Map containing a key | value of reaction | reactionsCount. For ex., “like” | 20
reach
Integer
Count of reach of the story
impression
Integer
Count of impression of the story
creatorId
String
ID of the user who created the story
expiresAt
DateTime
Date/time the story expires
createdAt
DateTime
Date/time the story was created
Name
Data Type
Description
targetType
Enum
Type of target
targetId
String
ID of target
updatedAt
DateTime
Date/time the story target was updated
hasUnseen
Boolean
Flag indicates whether the StoryTarget possesses unseen stories.
The 'getStoryTarget()
' function in the AmitySDK enables real-time observation of StoryTarget based on specified target. This function returns a LiveObject of StoryTarget, enabling users to receive updates and check whether the target possesses unseen stories.
This function requires two parameters: targetType, targetId.
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.
There are two types of story deletion: soft delete and hard delete. When a story is soft deleted, it is simply marked as deleted, with the isDeleted flag set to true in the database. The story still exists in the database, but is no longer visible to users. By contrast, when a story is hard deleted, all associated data, including reactions, comments is permanently removed from the database. This makes it impossible to retrieve the data once it has been hard deleted. Note that both soft delete and hard delete permanently remove unsynced stories from cache.
The 'softDeleteStory()
' function allows users to mark a story as deleted on the server, rendering it inaccessible to users.
This function requires one parameter: 'storyId.' Here's an explanation of the function parameter:
storyId
: Corresponds to the ID of the story.
The 'hardDeleteStory()
' function permanently deletes the story and all associated data, including reactions and comments from the server.
This function requires one parameter: 'storyId.' Here's an explanation of the function parameter:
storyId
: Corresponds to the ID of the story.
The Story Impression feature is a tool designed to collect valuable data regarding story interactions for analytics and reporting purposes. This feature empowers users to gain insights into how their content is performing and who is actively engaging with it. With this feature, users can mark specific stories as seen and access information about impressions, reach, and the list of users who have viewed each story.
Impressions represent the number of users who viewed the story, while reach represents the number of unique users who viewed the story. Please keep in mind that story impression data won't be updated in real-time but rather almost in real-time.
The 'markAsSeen()
' function in the AmitySDK serves to increase the impression and reach count of specific stories while promptly updating the 'isSeen' state of the story.
Info: In order to mark a story as seen, that story must be in sync state "SYNCED".
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 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.
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.