Firework for Developers
One-to-one Virtual ShoppingBusiness Portal
  • Welcome to Firework for Developers
  • Firework Interactive Video and One-to-many Digital Showroom
  • Web
    • Getting Started (Web)
      • Shopify
      • Magento
      • Wordpress (WooCommerce)
      • Salesforce Commerce Cloud
      • BigCommerce
    • Integration Guide for Web
      • Components
        • Hero Unit
        • Carousel / Grid
        • Storyblock (Web)
        • Player (Floating)
        • Storylink
      • Styling
      • Feed Attributes
      • Player
        • Configuration
          • Appearance
      • Video customization
        • Video Factory
        • CTA Button
        • Product cards
      • Events
        • Embed Feed and Storyblock Events
        • Video player events
        • Live stream events
        • Shopping events
      • Shopping Integration (V2)
        • Introduction
        • Shopping APIs
        • Product Hydration
        • Product Factory
        • Cart Sync
        • Tracking
          • Purchase
          • Add to cart
          • Remove from cart
          • Page viewed
        • Shopping Integration FAQ
        • Migrate from V1
      • Web SDK
      • Enhanced Picture-in-Picture
      • Privacy settings
        • Tracking settings
        • Cookies management
        • Content Security Policy
    • Telemetry console
    • Firework Service Domains
    • FAQ & Troubleshooting (Web)
  • Android SDK
    • Integration Guide for Android SDK
      • Getting Started (Android)
      • Video Feed (Android)
        • Video Feed Layouts (Android)
        • Channel Feed (Android)
        • Discover Feed (Android)
        • Playlist Feed (Android)
        • Dynamic Content Feed
        • Channel Hashtags Feed
        • Sku Feed
        • Single Content Feed
        • Configure Video Feed
      • Customization
        • CTA
      • Analytics (Android)
      • Shoppable Videos (Android)
        • Product Hydration
      • Live Stream Support (Android)
      • Video Player (Android)
      • StoryBlock (Android)
      • Share & Video Deep linking
      • Ad Support (Android)
      • Configure Video Advertisements Source (Android)
      • In-app Language Switches
      • Compose support(Android)
    • Sample App (Android)
    • FAQ & Troubleshooting (Android)
    • Changelog (Android)
  • iOS SDK
    • Integration Guide for iOS SDK
      • Getting Started (iOS)
      • ATT compliance (iOS)
      • Video Feed (iOS)
        • Discover Feed(iOS)
        • Channel Feed (iOS)
        • Playlist Feed (iOS)
        • Playlist Group Feed (iOS)
        • Dynamic Content (iOS)
        • Hashtag Playlist (iOS)
        • SKU Playlist (iOS)
        • Video Ads (iOS)
        • Video Feed Layouts (iOS)
      • Story Block (iOS)
      • Customization (iOS)
        • Video feed configurations (iOS)
        • Player configurations (iOS)
        • Shopping configurations (iOS)
          • Customize product card on videos using the custom view (iOS)
        • Customize click behaviors (iOS)
      • Shopping (iOS)
      • Live Stream Support (iOS)
      • Analytics (iOS)
      • Share & Deeplinking(iOS)
      • Ad Support (iOS)
    • Sample App (iOS)
    • FAQ & Troubleshooting (iOS)
    • Changelog (iOS)
  • React Native SDK
    • Integration Guide for React Native SDK V2
      • Getting Started (React Native)
      • ATT compliance React Native (iOS)
      • Video Feed (React Native)
      • Story Block (React Native)
      • Customization (React Native)
        • Video feed configurations (React Native)
        • Player configurations (React Native)
        • Shopping configurations (React Native)
          • Customize product card on videos using the custom view (React Native)
        • Customize click behaviors (React Native)
      • Shopping (React Native)
      • Live Stream Support (React Native)
      • Ad Support (React Native)
      • Analytics (React Native)
      • App-level Language Setting (React Native)
      • Share & Video Deeplinking (React Native)
      • Android Style (React Native)
      • Inject Android Image Loader (React Native)
      • Integrate SDKs in Hybrid React Native and native Apps
      • Reference (React Native)
      • Sample App (React Native)
      • FAQ & Troubleshooting (React Native)
      • Changelog (React Native)
  • Flutter SDK
    • Integration Guide for Flutter SDK V2
      • Getting Started (Flutter)
      • ATT compliance Flutter (iOS)
      • Video Feed (Flutter)
      • Story Block (Flutter)
      • Customization (Flutter)
        • Video feed configurations (Flutter)
        • Player configurations (Flutter)
        • Shopping configurations (Flutter)
          • Customize product card on videos using the custom view (Flutter)
        • Customize click behaviors (Flutter)
      • Live Stream Support (Flutter)
      • Shopping (Flutter)
      • Ad Support (Flutter)
      • Analytics (Flutter)
      • App-level Language Setting (Flutter)
      • Share & Video Deeplinking (Flutter)
      • Inject Android Image Loader (Flutter)
      • Android Style (Flutter)
      • Integrate SDKs in Hybrid Flutter and native Apps
      • Reference (Flutter)
      • Sample App (Flutter)
      • FAQ & Troubleshooting (Flutter)
      • Changelog (Flutter)
  • Help Articles
    • Importing Products to Firework
    • Adding products to a video
    • Displaying product videos on product pages using hashtag filtering(Web)
    • Syncing Carts
    • Encoded IDs
Powered by GitBook
On this page
  • Display Story Block
  • Story Block Content Source
  • Receive story block events
  • Play and pause StoryBlock programmatically
  • Player configurations

Was this helpful?

  1. iOS SDK
  2. Integration Guide for iOS SDK

Story Block (iOS)

Display Story Block

Use StoryBlockViewController

Integration

  1. Import FireworkVideo.

  2. Create a new StoryBlockViewController.

  3. Embed instantiated StoryBlockViewController.

import FireworkVideo

class ViewController: UIViewController {

    func embedFeedInViewController() {
        let storyBlockVC = StoryBlockViewController(source: .discover)
        // Please ensure that viewConfiguration and isPictureInPictureEnabled are set
        // before attaching it to the parent view
        storyBlockVC.viewConfiguration = getStoryBlockConfiguration()
        storyBlockVC.isPictureInPictureEnabled = true

        self.addChild(storyBlockVC)

        storyBlockVC.view.translatesAutoresizingMaskIntoConstraints = false
        self.view.addSubview(storyBlockVC.view)
        NSLayoutConstraint.activate([
            storyBlockVC.view.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
            storyBlockVC.view.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
            storyBlockVC.view.heightAnchor.constraint(equalToConstant: 500),
            storyBlockVC.view.centerYAnchor.constraint(equalTo: self.view.centerYAnchor)
        ])

        storyBlockVC.didMove(toParent: self)
    }

    func getStoryBlockConfiguration() -> StoryBlockConfiguration {
        var viewConfiguration = StoryBlockConfiguration()
        viewConfiguration.playbackButton.isHidden = false
        viewConfiguration.fullScreenPlayerView.playbackButton.isHidden = false
        return viewConfiguration
    }
}

Presently, it is necessary to configure the story block before it is attached to the parent view, due to a limitation in the current implementation.

Use StoryBlockView

The StoryBlockView provides a UIView wrapper for the FireworkVideo.StoryBlockViewController. You can customize the StoryBlockView just like the FireworkVideo.StoryBlockViewController.

Integration

  1. Import FireworkVideo and FireworkVideoUI.

  2. Instantiate StoryBlockView and embed it.

The following are the sample codes:

import UIKit
import FireworkVideo
import FireworkVideoUI

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        self.addStoryBlockView()
    }

    func addStoryBlockView() {
        let storyBlockView = StoryBlockView(source: .discover)
        // Please ensure that viewConfiguration and isPictureInPictureEnabled are set
        // before attaching it to the parent view
        storyBlockView.viewConfiguration = getStoryBlockConfiguration()
        storyBlockVC.isPictureInPictureEnabled = true

        storyBlockView.translatesAutoresizingMaskIntoConstraints = false
        self.view.addSubview(storyBlockView)

        NSLayoutConstraint.activate([
            storyBlockView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
            storyBlockView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
            storyBlockView.heightAnchor.constraint(equalToConstant: 500),
            storyBlockView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor)
        ])
    }

    func getStoryBlockConfiguration() -> StoryBlockConfiguration {
        var viewConfiguration = StoryBlockConfiguration()
        viewConfiguration.playbackButton.isHidden = false
        viewConfiguration.fullScreenPlayerView.playbackButton.isHidden = false
        return viewConfiguration
    }
}

Presently, it is necessary to configure the story block before it is attached to the parent view, due to a limitation in the current implementation.

Use StoryBlockSwiftUIView(SwiftUI)

The StoryBlockSwiftUIView provides a SwiftUI View wrapper for the FireworkVideo.StoryBlockViewController. You can customize the StoryBlockSwiftUIView just like the FireworkVideo.StoryBlockViewController.

Integration

  1. Import FireworkVideo and FireworkVideoUI.

  2. Instantiate StoryBlockSwiftUIView and embed it.

The following are the sample codes:

import SwiftUI
import FireworkVideo
import FireworkVideoUI

struct ContentView: View {
    var body: some View {
        List {
            Spacer()
            StoryBlockSwiftUIView(
                source: .discover,
                viewConfiguration: getStoryBlockConfiguration(),
                isPictureInPictureEnabled: true,
                onStoryBlockLoaded: {
                    debugPrint("Story block loaded successfully.")
                },
                onStoryBlockFailedToLoad: { error in
                    debugPrint("Story block did fail loading.")
                }
            ).frame(height: 500)
            Spacer()
        }
    }

    func getStoryBlockConfiguration() -> StoryBlockConfiguration {
        var viewConfiguration = StoryBlockConfiguration()
        viewConfiguration.playbackButton.isHidden = false
        viewConfiguration.fullScreenPlayerView.playbackButton.isHidden = false
        return viewConfiguration
    }
}

Story Block Content Source

The enum StoryBlockContentSource defines the different sources that can be used to populate the story block. The content source must be specified when the StoryBlockViewController is instantiated; StoryBlockViewController(source: .discover). By default, the feed will use the .discover content source.

Other content sources include

Channel

Displays content from the specified channel id.

Note: The user will only see videos they have not viewed before. If the user has viewed all the videos for a channel similar videos will automatically be provided.

let channelID = "<Channel ID>"
let storyBlockVC = StoryBlockViewController(source: .channel(channelID: channelID))

Channel Playlist

Displays content from the specified playlist id.

let channelID = "<Your Channel ID>"
let playlistID = "<Playlist ID>"
let storyBlockVC = StoryBlockViewController(source: .channelPlaylist(channelID: channelID, playlistID: playlistID))

Dynamic Content

Displays dynamic content based on the provided channel id and content parameters.

let channelID = "<Channel ID>"
let parameters: DynamicContentParameters = ["<cohort key>": ["<cohort value 1>", "<cohort value 2>"]]
let storyBlockVC = StoryBlockViewController(source: .dynamicContent(channelID: channelID, parameters: parameters))

Hashtag Playlist

Displays content based on the provided channel id and the hashtag expression.

let channelID = "<Channel ID>"
let singleHashtag = "dogs"
let storyBlockVC = StoryBlockViewController(source: .hashtagPlaylist(channelID: channelID, filterExpression: singleHashtag))

Or a more advanced hashtag expression can be used to fine tune the results

let channelID = "<Channel ID>"
let filterExpression = "(and sport (or food comedy))"
let storyBlockVC = StoryBlockViewController(source: .hashtagPlaylist(channelID: channelID, filterExpression: filterExpression))

Single Video or Live Stream

Displays a single video or live stream content.

let videoOrLiveStreamID = "<Video or LiveStream ID>"
let storyBlockVC = StoryBlockViewController(source: .singleContent(videoOrLiveStreamID: videoOrLiveStreamID))

Video Ads

Displays video ads based on vast XML.

// Specifies which channel the video ads should be created under.
let adChannelId = "<Channel ID>"
// The vast XML.
let vastXml = "<Vast XML>"
let storyBlockVC = StoryBlockViewController(source: .videoAds(adChannelId: adChannelId, vastXml: vastXml))

Receive story block events

  1. Set the delegate

storyBlockVC.delegate = self
  1. Conform to StoryBlockViewControllerDelegate protocol

func storyBlockDidLoadFeed(
    _ viewController: StoryBlockViewController
) {
    debugPrint("Story block loaded successfully.")
}

func storyBlock(
    _ viewController: StoryBlockViewController,
    didFailToLoadFeed error: StoryBlockError
) {
    debugPrint("Story block did fail loading.")
    if case .contentSourceError(let feedContentSourceError) = error,
       case .emptyFeed = feedContentSourceError {
        // This is a specific error.
        // SDK will trigger this error when the story block is empty.
        // For example, this error will be triggered when loading an empty playlist.
    } else {
        // Other error
    }
}

Play and pause StoryBlock programmatically

Use StoryBlockViewController

let storyBlockVC = StoryBlockViewController(source: .discover)

// Play StoryBlock Programmatically
storyBlockVC.play()

// Pause StoryBlock Programmatically
storyBlockVC.pause()

Use StoryBlockView

let storyBlockView = StoryBlockView(source: .discover)

// Play StoryBlock Programmatically
storyBlockView.play()

// Pause StoryBlock Programmatically
storyBlockView.pause()

Player configurations

PreviousVideo Feed Layouts (iOS)NextCustomization (iOS)

Last updated 3 months ago

Was this helpful?

Follow the to install FireworkVideoUI.

Follow the to install FireworkVideoUI.

Note: Unlike the , only content in the playlist will be shown to the user.

Please refer to .

instruction
instruction
channel content source
Player configurations (iOS)