Quick Start

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.

Installation

🚧

Warning

Storyly Moments SDK targets iOS 11 or higher.

📘

Tip

You can find the latest version’s release notes here.

CocoaPods

Storyly Moments SDK is available through CocoaPods. 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 version should be 1.9+

Carthage

Storyly Moments SDK is available through Carthage. 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 it, add it from Add Other > Add files dialog. Frameworks will be located at Carthage/Build/.

🚧

Warning

Please note that Carthage 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.

self.storylyMoments = StorylyMomentsManager(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

let config = MomentsConfig.Builder()
    .build(momentsToken:MOMENTS_TOKEN, userPayload: USER_PAYLOAD)

📘

Tip

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.

🚧

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.

self.storylyMoments = StorylyMomentsManager(config: 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 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 openStoryCreator(mediaImport: Media? = nil)

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

Open User Stories

Using this function, you can let your users view their live Stories by opening the 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 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:

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 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 creation process or show the 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 into what your user intends to do in Storyly Moments, such as opening the gallery to create a Story or opening the user Stories to preview.

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

// the class(indicated with self) extends StorylyMomentsDelegate
self.storylyMoments.momentsDelegate = self

extension ViewController: StorylyMomentsDelegate {
  // Override event functions 
}

🚧

Warning

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