Stagecast

Overview

The SDK consists of only one function - a function to retrieve a UIViewController that, when presented, will show the Stagecast moment list view. It is up to the surrounding application to present the UIViewController in a manner that fits with the application’s current view hiearchy which will hand over the control to the Stagecast SDK to render Stagecast moments etc.

Stagecast

All functionality can currently be found in the SCApi class.

How it works

The SDK communicates with its backend to fetch information about launched moments, where a moment can be anything from something that uses the flash to blink or something that changes the colour of the screen to something that asks the user to take filter photos and participate in games - basically anything you can launch from the web frontend side of the Stagecast service.

In order to launch moments you need an account on https://stagecast.se/login where you can edit and control the event that the SDK is configured for. You configure the moments to launch and finally launch them to the crowd.

If the Stagecast SDK ViewController is open and showing on the screen it will discover by itself when a moment is launched and will render the moment on the screen. If the app is in the background, shut off or if the phone is completely put away there is however a need to wake the user up with a notification that should alert the user to open the app. It is the responsibility of the surrounding app, NOT the SDK, to, when the app is opened from a notification associated with a moment launch, get the view controller from the Stagecast API and present the view controller without user intervention. To make the integration complete there will also be a need to integrate the Stagecast backend with whatever method of sending notifications that the application is using so that, when the operator of the event launches a moment in Stagecast, the Stagecast backend can trigger a notification to be sent to the users of the app.

Example

To run the example project, clone the repo, install the required plugin (see ‘installation’ below) and run pod install from the Example directory. The example app is however very trivial. It is just a button that, when clicked, does the following:

import UIKit
import sc_moments

class SCRootViewController : UIViewController {

    @IBAction func buttonPressed(_ sender: Any) {
        let props = [
            "event":"99C72069-E1D2-496C-BF9A-93EC4E7E3F69",
            "headerTitle":"Moments",
            "headerBgColor":"black",
            "headerTintColor":"white"
        ]

        if let vc = SCApi.getViewController(props) {
            self.present(vc, animated: false)
        }
    }
}

You should ask the Stagecast team on what event ID to use for development purposes and for production environment.

Info.plist requirements

The SDK puts one requirement on the surrounding app’s Info.plist and that is that it should set UIViewControllerBasedStatusBarAppearance key in Info.plist to NO. This is due to the needs of the navigation controller running inside the SDK

Installation

sc_moments is available through CocoaPods. The dependency to react native however introduces some extra dependencies in your Podfile. The suggested procedure for integrating sc_moments into your project is therefore the following:

1. Download an sc_moments release (take the latest unless told otherwise) and untar it somewhere on your computer.

Releases MD5 Date
sc_moments-0.0.21        d77d623f14971119c605970a48b00d04         2019-02-08
sc_moments-0.0.20        664ec3478ebcc9fcec55e1768f824f2a         2019-01-23
sc_moments-0.0.17       5218936fb39bd71f95891355c9b94ed7          2019-01-19

2. Add pod dependencies (and use_frameworks! in order to avoid using a bridging header) to your project’s Podfile. Note: in the first line you enter the path of the folder to where you cloned the repo above - like ‘/Users/someuser/projects/sc_moments’. Also replace the ‘target’ with whatever target you have in your project.

sc_moments_path = 'path-to-where-you-cloned-sc_moments-repo'

node_modules_path = File.join(sc_moments_path, 'node_modules')
react_path = File.join(node_modules_path, 'react-native')
yoga_path = File.join(react_path, 'ReactCommon/yoga')
folly_spec_path = File.join(react_path, 'third-party-podspecs/Folly.podspec')
glog_spec_path = File.join(react_path, 'third-party-podspecs/glog.podspec')
double_conversion_spec_path = File.join(react_path, 'third-party-podspecs/DoubleConversion.podspec')
react_native_gesture_handler_path = File.join(node_modules_path, 'react-native-gesture-handler/RNGestureHandler.podspec')
react_native_linear_gradient_path = File.join(node_modules_path, 'react-native-linear-gradient/BVLinearGradient.podspec')
react_native_languages_path = File.join(node_modules_path, 'react-native-languages/RNLanguages.podspec')
react_native_keep_awake_path = File.join(node_modules_path, 'react-native-keep-awake/react-native-keep-awake.podspec')

target 'your_target' do
  use_frameworks!

  pod 'sc_moments', :path => sc_moments_path
  pod 'React', path: react_path, subspecs: ['DevSupport']
  pod 'yoga', path: yoga_path
  pod 'Folly', podspec: folly_spec_path
  pod 'DoubleConversion', podspec: double_conversion_spec_path
  pod 'glog', podspec: glog_spec_path
  pod 'RNGestureHandler', podspec: react_native_gesture_handler_path
  pod 'BVLinearGradient', podspec: react_native_linear_gradient_path
  pod 'RNLanguages', podspec: react_native_languages_path
  pod 'react-native-keep-awake', podspec: react_native_keep_awake_path
end

3. Update your project with the new dependencies

pod install

Note: It is normal to see an error such as [!] Failed to resolve dependencies, so pre-patch was not applied, please try running `pod install` again to apply the patch. from running this script. This message can be ignored.

4. Set UIViewControllerBasedStatusBarAppearance key in the Info.plist of your app to NO

5. Run and build your project in xcode

Author

Stagecast, sdk@stagecast.se