# Quick Start

This walkthrough shows how to add Storyly Moments to your iOS 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

WARNING

Storyly Moments SDK targets iOS 11 or higher.

# CocoaPods

Storyly Moments SDK is available through CocoaPods (opens new window). To integrate Storyly Moments SDK into your Xcode project using CocoaPods, specify it in your Podfile:

use_frameworks!
pod 'StorylyMoments'

Then run pod install.

WARNING

Please note that CocoaPods (opens new window) version should be 1.9+

# Carthage

Storyly Moments SDK is available through Carthage (opens new window). To integrate Storyly Moments SDK into your Xcode project using Carthage, specify it in your Cartfile:

binary "https://prod-storyly-media.s3.eu-west-1.amazonaws.com/storyly-moments-sdk/Carthage/StorylyMoments.json"

Then run carthage update --use-xcframeworks.

After, add the frameworks to your Xcode project: Go to targets and select your application. Click plus button from the Frameworks, Libraries, and Embedded Content section and add StorylyMoments.xcframework. If you can't find, add from Add Other > Add files dialog. Frameworks will be located at Carthage/Build/.

WARNING

Please note that Carthage (opens new window) version should be 0.38+

# Import Storyly Moments

You need to import related modules to use Storyly Moments:

import StorylyMoments

# Initialize Storyly Moments

Basic usage of Storyly Moments requires initialization of StorylyMomentsManager with a Config parameter. storylyMomentsDelegate is not required to initialize StorylyMomentsManager, but if you want to be informed about Storyly Moments events then you need to provide your delegate with this parameter. You can find more information about this StorylyMomentsDelegate in Set up Delegate section.

self.storylyMoments = StorylyMomentsManager(config: Config, storylyMomentsDelegate: StorylyMomentsDelegate? = nil)

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.

self.storylyMomentsConfig = Config(momentsToken: String, userPayload: String)

WARNING

Do not forget to set rootViewController variable of Storyly Moments instance as your view controller.

self.storylyMoments.rootViewController = self

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

var storylyMoments = StorylyMomentsManager(config: Config(momentsToken: MOMENTS_TOKEN, userPayload: USER_PAYLOAD), momentsDelegate: self)

# 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:

public func createStory(mediaImport: MediaImport? = nil)

After you call createStory function without mediaImport 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 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 mediaImport parameter, your users will be directed to story sharing screen straight away with the provided media. For more information about MediaImport (opens new window) class please check API reference (opens new window).

# 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:

public convenience init(storylyId: String, storylyPayload: String) {
    self.init(storylyId: storylyId)
    self.storylyPayload = storylyPayload
}

If you have already connected your Storyly Moments instance to your Storyly instance of your application from dashboard and initialize the Storyly 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 the following momentsItems variable of StorylyView:

public var momentsItems: [MomentsItem]?

WARNING

Assigned custom views will be the initial story groups and their places will be fixed.

# Set up Delegate

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.

Storyly Moments notifies application when an event occurs. You can adopt StorylyMomentsDelegate protocol 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 StorylyMomentsDelegate 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 delegate:

func 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 delegate:

func 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:

func 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:

func onUserStoriesLoadFailed(errorMessage: String)