Quick Start

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.

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 Maven Central

You can find the latest versionโ€™s release notes here.

๐Ÿšง

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)

Storyly Moments Configuration

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.

๐Ÿšง

Warning

val config = MomentsConfig.Builder()
    .build(MOMENTS_TOKEN, USER_PAYLOAD)

You need to set StorylyMomentsManager to call main functions of Storyly Moments.

var momentsManager = StorylyMomentsManager(context: this, config)

๐Ÿ“˜

Optional

If you'd like to do the other configurations, please check Configuration section.

Main Functions

Storyly Moments presents two basic functions for your users. These are Create and Share Story and Open User Stories which is 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 openStoryCreator()
or
fun openStoryCreator(uri: Uri)

After you call openStoryCreator function without uri parameter, if your users give the 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 the 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 the share Story screen, users can review the selected media, and they can either discard or share media. After the upload and share process is successful, users will be directed to My Stories screen to see their newly created Stories.

If you call openStoryCreator function with uri parameter, your users will be directed to Story sharing screen straight away with the provided media.

Open User 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:

fun openUserStories()

Initiate Main Functions From Storyly Bar

For your application users to see the Stories of their followers, you should integrate Storyly SDK 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 the dashboard and initialize the Storyly instance by sending the user payload through storylyPayload parameter, users will be able to see the 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 the Story create a process or show the 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 into what your user intends to do in Storyly Moments, such as opening a gallery to create a Story or opening the user Stories to preview.

MomentsListener notifies the application when an event occurs. You can adapt MomentsListener interface in your code, and then override its functions to learn about specific events, which will be explained in the Events section.

storylyView.storylyMomentsListener = object : StorylyMomentsListener {  
    // Override event functions  
}

๐Ÿšง

Warning

Do not forget to provide the class that adopts MomentsListener in Storyly Moments setup.