# Quick Start
This walkthrough shows how to add Storyly Moments to your Android application and forward your users to create their own stories.
Before you begin
This walkthrough requires a user payload which is explained in user payload section and a Storyly Moments token which is retrieved from Storyly Dashboard (opens new window).
# Installation
First, declare the dependency for the Storyly Moments SDK in your app’s module Gradle file (usually app/build.gradle
).
android {
dependencies {
...
// You should add this line
implementation 'com.appsamurai.storyly:storyly-moments:<latest-version>'
...
}
}
TIP
Please do not forget to replace <latest-version>
. The latest version is (opens new window)
WARNING
Storyly Moments SDK targets Android API level 17 (Android 4.2, Jelly Bean)
or higher.
# Import Storyly Moments
You need to import related packages to use Storyly Moments:
import com.appsamurai.storyly.moments
# Initialize Storyly Moments
Basic usage of Storyly Moments requires initialization of StorylyMomentsManager
with a Config
parameter.
val storylyMoments = StorylyMomentsManager(context: Context, config: Config)
Configuration of StorylyMomentsManager
is done by Config
parameter. Initialization of Config
requires two string parameters, one of them is user payload and the other one is Storyly Moments token. You can get your Storyly Moments token from the Storyly Dashboard -> Settings -> Moments (opens new window). For more information about the user payload please check User Payload section.
val config = Config(momentsToken: String, userPayload: String)
You need to set StorylyMomentsManager
to call main functions of Storyly Moments
.
var momentsManager = StorylyMomentsManager(context, Config(
STORYLY_INSTANCE_TOKEN,
USER_PAYLOAD
))
# Main Functions
Storyly Moments presents two basic functions for your users. These are Create and Share Story and Open My Stories which will be explained below:
# Create and Share Story
After Storyly Moments is initialized, you are ready to direct your users to create their first story by calling the following function using your Storyly Moments instance:
fun createStory()
or
fun createStory(uri: Uri)
After you call createStory
function without uri
parameter, if your users give necessary permission, they will be directed to their media library. For more information about permissions and their effects on story creation please check Permissions section. In media library, your users can take the following actions:
- Select a single media to share
- Select multiple media to share
- Open camera to capture media (If permission is given)
Selecting one of these options will open a share story screen for the last review of the media. In share story screen, users can review the selected media and they can either discard or share media. After upload and share process is successful, users will be directed to my stories screen to see their newly created stories.
If you call createStory function with uri
parameter, your users will be directed to story sharing screen straight away with the provided media.
# Open My Stories
Using this function, you can let your users view their live stories by opening my stories screen. In my stories screen, your users are able to check who has seen or liked their stories. They can also delete their live stories. You can direct your users to this screen using the following function:
public func openMyStories()
# Initiate Main Functions From Storyly Bar
For your application users to see the stories of their followers, you should integrate Storyly SDK (opens new window) into your application. For this, you should initialize your Storyly instance by passing the user payload to the storylyPayload
parameter as follows:
StorylyInit (
val storylyId: String,
val storylyPayload: String?
)
If you have already connected your Storyly Moments* instance to your Storyly instance of your application from dashboard and initialize the Storyly Moments* instance by sending the user payload through storylyPayload
parameter, users will be able to see stories of their followers by default.
In addition to these follower story groups, Storyly SDK allows you to add custom Storyly Moments views in order to initiate story create process or show user's own stories from Storyly bar. You can create your own views and assign those views to StorylyView
by setMomentsItem
:
fun setMomentsItem(momentsItems: List<MomentsItem>)
WARNING
Assigned custom views will be the initial story groups and their places will be fixed.
# Set up Listener
This walkthrough shows you how to handle Storyly Moments events in your app. Storyly Moments events provide insight on what your user intend to do in Storyly Moments such as opening gallery to create story or opening the user stories to preview.
MomentsListener
notifies application when an event occurs. You can adopt MomentsListener
interface in your code, and then override its functions to learn about specific events, which will be explained in the next sections.
WARNING
Do not forget to provide the class that adopts MomentsListener
in Storyly Moments setup.
# onOpenCreateStory 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 listener:
fun onOpenCreateStory(isDirectMediaUpload: Bool)
# onOpenMyStory 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 listener:
fun onOpenMyStory()
# 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 listener:
fun onUserStoriesLoaded(momentsStoryGroup: MomentsStoryGroup?)
# onUserStoriesLoadFailed Event
This event will let you know that your loading of user stories loading is failed.errorMessage
parameter denotes fail reason of the loading. In order to be notified about this event, override the following function in your listener:
fun onUserStoriesLoadFailed(errorMessage: String)