iOS SDK
This guide describes how to add and use StorySDK to your iOS app.
Installation
Swift Package Manager
To install StorySDK using Swift Package Manager, follow these steps:
Open your project in Xcode and go to
File > Swift Packages > Add Package Dependency.In the search field, enter
https://github.com/StorySDK/ios-sdk.gitand click Next.Select the version rule "Up to Next Major" and enter "1.0.0" in the text field.
Click Next and then Finish.
CocoaPods
To install StorySDK using CocoaPods, add the following to your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '13.0'
use_frameworks!
target 'MyApp' do
pod 'StorySDK', '~> 1.0'
endThen, run the following command:
Carthage
To install StorySDK using Carthage, add the following to your Cartfile:
Then, run the following command:
Usage
Make sure to import the project wherever you may use it:
Setup Story Witget

To use the SDK, you need to obtain a token from the StorySDK dashboard. You can find your token in the Settings section of the dashboard at https://app.storysdk.com/dashboard/.
Further we consider that
Integration
Define Groups Widget in your UIViewController
Get information about the SDK application:
Get the groups of the app and then call widget.load():
You can use the Groups Widget to display groups of stories in your app. Create and add the widget to your view hierarchy:
Layout widget:
Conform SRStoryWidgetDelegate protocol and implement openStories action:
When your app is ready to load groups, call widget.load().
⚡️ Please note that in order for stories to be displayed in the SDK, they need to be published.
Onboarding

To add onboarding to your app, follow these steps:
First, create an onboarding in the Onboarding section of the dashboard at https://app.storysdk.com/dashboard/ and copy your Onboarding ID from Onboarding Settings
Then conform
SRStoryWidgetDelegateprotocol and fill some methods such implementation (here we've addeddismissfunc that call paywall screen andratefunc that request rate the app on second onboarding screen, this is a standard approach, you can implement similar or completely different behavior as you wish)
Caching (optional but useful step)
Often, to load stories faster, for example, to build onboarding in an app especially if you have video files in your stories, you may need to get them without waiting for loading from the server. In this case, caching will help you:
Caching is provided using a couple of lanes fastlane and consists of a few simple steps:
Install fastlane first (by running the fastlane command in the root of the project) and then follow the step above.
After run
where groupId is the id of the group that contains the media files you want to cache. If successful, you will see your media files in the "fastlane/cached" directory.
Now it’s enough to add these files to the Xcode project, like resources via Add Files to... action so that they end up in the bundle of your app, that’s all - in this form StorySDK can already see them. Caching is now complete.
Direct API
To show the stories of a selected group using the top view controller:
Configuration
a) Set language
b) Set full screen on / off
c) Show title on / off
d) Filter (hide) onboarding on / off
e) Set show time duration for each story
f) Set progress color
Advanced
StorySDK has a nice default loader. If you prefer to replace it with another one, that it also possible. Ensure your custom loader confirms SRLoader protocol:
You can just remove the loader if you don't need it:
Or use the your own custom loaders, here are some examples:
or even
In additional you also can handle custom method defined in dashboard (using onWidgetMethodCall from SRStoryWidgetDelegate protocol) for instance define action on onboarding close event or request rate your during onboarding. Like this:
License
StorySDK is available under the MIT license. See the LICENSE file for more info.
Example project
You can see an example of usage here.
Last updated
Was this helpful?