API: Option

    API: Option


    Article summary

    setShareScheme

    Set the scheme to be passed to the system share popup when Share is selected (tapped). By setting shareDelegate, you can implement a custom share popup instead of the iOS system share popup.

    setShareScheme(_ scheme: String?, shareDelegate: ShopLivePlayerShareDelegate?)

    Parameter name

    Type

    Description

    scheme

    String?

    Scheme or URL to share

    shareDelegate

    ShopLivePlayerShareDelegate?

    ShopLiveShareDelegate

    Sample code

    let scheme = "shoplive://live"
    let scheme = "https://shoplive.cloud/live"
    
    class ViewController : UIViewController {
      
      func viewDidLoad(){ 
    		ShopLive.setShareScheme(scheme, shareDelegate: nil)
      }
    } 
    extension ViewController : ShopLiveShareDelegate { 
      func handleShare(data : ShopLivePlayerShareData) {
        //show share sheet
      }
    }

    ShopLivePlayerShareData

    Parameter name

    Type

    Description

    campaign

    ShopLivePlayerShareCampaign?

    Information about current broadcast campaigns

    url

    String?

    Scheme or URL to share

    ShopLivePlayerShareCampaign

    Parameter name

    Type

    Description

    campaignKey

    String?

    The campaignKey of the current broadcast

    title

    String?

    Current broadcast

    descriptions

    String?

    Description of the current broadcast

    thumbnail

    String?

    Thumbnail image of the current broadcast


    setChatViewFont

    Set the chat font and chat send button font.

    setChatViewFont(inputBoxFont: UIFont, sendButtonFont: UIFont)

    Parameter name

    Type

    Description

    inputBoxFont

    UIFont

    Chat font

    sendButtonFont

    UIFont

    Chat send button font

    Sample code

    /**
        let inputDefaultFont = UIFont.systemFont(ofSize: 14, weight: .regular)
    
        let sendButtonDefaultFont = UIFont.systemFont(ofSize: 14, weight: .medium)
    
    */
    
    let customFont = UIFont(name: "{Custom Font}", size: 16)
    
    ShopLive.setChatViewFont(inputBoxFont: customFont, sendButtonFont: customFont)
    


    setLoadingAnimation

    Set the video loading progress to image animation.

    setLoadingAnimation(images: [UIImage])

    Parameter name

    Type

    Description

    images

    UIImage array

    An array of UIImage to use for image animation.

    Sample code

    var images: [UIImage] = []
    
    for i in 1...11 {
        images.append(.init(named: "loading\(i)")!)
    }
    
    ShopLive.setLoadingAnimation(images: images)
    


    setInAppPipConfiguration

    Set the InAppPip related options. Values ​​set with the setInAppPipConfiguration(config:) have priority over values ​​set with previously deprecated APIs.

    setInAppPipConfiguration(config: ShopLiveInAppPipConfiguration?)

    Parameter name

    Type

    Description

    pipSize

    ShopLiveInAppPipSize

    • init(pipMaxSize : CGFloat)

    • init(pipFixedHeight : CGFloat)

    • init(pipFixedWidth : CGFloat)

    • For pipMaxSize, it is set to .scaleAspectFill. For example, if pipMaxSize is 100,

      • In landscape mode, it will be width 100, height 100 x (video ratio)

      • In portrait mode, it will be height 100, width 100 x (video ratio)

    Parameter name

    Type

    Description

    config

    ShopLiveInAppPipConfiguration

    • pipSize: ShopLiveInAppPipSize

    • useCloseButton: Bool

      • (Set whether to show the close button at the top left in InAppPip. Default: false)

    • pipPosition: ShopLive.PipPosition

      • (Default: .bottomRight)

    • enableSwipeOut: Bool

      • (Whether to close the in-app PIP by moving it off the screen) Set. Default: false)  

    • pipRadius: CGFloat

      • (Set the cornerRadius of in-app PIP.  default : 10)

    In an Objective-C environment, use the ShopLivePlayerDataObjc object.

    Sample code

    //maxSize
    let pipSize = ShopLiveInAppPipSize(pipMaxSize : 200)
    //fixedHeight
    let pipSize = ShopLiveInAppPipSize(pipFixedHeight : 200)
    //fixedWidth
    let pipSize = ShopLiveInAppPipSize(pipFixedWidth  :200)
    
    let inAppPipConfig = ShopLiveInAppPipConfiguration(pipSize: pipSize,
                                                       useCloseButton: true,
                                                       pipPosition: .bottomLeft,
                                                       enableSwipeOut: true)
    ShopLive.setInAppPipConfiguration(config: inAppPipConfig)


    getPreviewSize

    Retrieve the size of a preview.

    getPreviewSize(inAppPipConfiguration: ShopLiveInAppPipConfiguration, videoRatio: CGSize) -> CGSize

    Parameter name

    Type

    Description

    inAppPipConfiguration

    ShopLiveInAppPipConfiguration

    ShopLiveInAppPipConfiguration

    videoRatio

    CGSize

    Video ratio (ex 16 : 9, 9 : 16)


    addSubViewToPreview

    Show customView on top of the Shoplive Preview.

    Be cautious that while showing customView on top of the Shoplive preview, be sure to set the ShopLiveInAppPipConfiguration(useCloseButton:false).

    addSubViewToPreview(subView: UIView)

    Sample code

    func setCustomerPreviewCoverView() {
        var previewViewCoverView = UIView()
        previewViewCoverView.addSubview(someView1)
        previewViewCoverView.addSubview(someView2)
        NSLayoutConstraint.activate([
            someView1.topAnchor.constraint(equalTo: previewViewCoverView.topAnchor),
            someView1.trailingAnchor.constraint(equalTo: previewViewCoverView.trailingAnchor),
            someView1.widthAnchor.constraint(equalToConstant: 70),
            someView1.heightAnchor.constraint(equalToConstant: 30),
                
            someView2.bottomAnchor.constraint(equalTo: previewViewCoverView.bottomAnchor),
            someView2.leadingAnchor.constraint(equalTo: previewViewCoverView.leadingAnchor),
            someView2.trailingAnchor.constraint(equalTo: previewViewCoverView.trailingAnchor),
            someView2.heightAnchor.constraint(equalToConstant: 40)
        ])
        ShopLive.addSubViewToPreview(subView: previewViewCoverView)
    }


    startPictureInPicture

    Switch from full screen mode to PIP mode.

    startPictureInPicture(with position: ShopLive.PipPosition, scale: CGFloat)
    startPictureInPicture()

    Parameter name

    Type

    Description

    position

    ShopLive.PipPosition

    Default position when PIP mode starts

    scale

    CGFloat

    A value between 0.0 and 1.0

    Sample code

    // 0.4 (Default) 
    ShopLive.startPictureInPicture()
    
    // Turn in to InAppPip with scale of 0.1 of fullScreen 
    ShopLive.startPictureInPicture(with: .bottomRight, scale: 0.1)
    
    // Turn in to InAppPip with scale of 0.8 of fullScreen 
    ShopLive.startPictureInPicture(with: .topLeft, scale: 0.8)

    Size setting sample

    Size

    PIP screen

    0.1

    0.4 (default)

    0.8


    stopPictureInPicture

    Switch PIP mode to full screen mode.

    stopPictureInPicture()

    Sample code

    ShopLive.stopPictureInPicture()


    hookNavigation

    When selecting a product or banner, you receive events directly through the custom Callback function set in the parameters (input navigation as a parameter).

    hookNavigation(navigation: @escaping ((URL) -> Void))

    Parameter name

    Type

    Description

    navigation

    URL

    Block called when selecting a product or banner

    • Delivers the URL of the selected product or banner

    Sample code

    ShopLive.hookNavigation { url in
           // url: The set URL of a selected product or a banner
           print("hookNavigation \(url)")
       }


    KeepWindowStyleOnReturnFromOsPip options

    setKeepWindowStyleOnReturnFromOsPip

    When using OS PIP, if the Shoplive Player is in a playing state (pip, fullscreen) and you move to the home screen or another app (switching to background state),

    causing the video to enter OS PIP, you can choose to either return to the last playing state (pip, fullscreen) or always switch to fullscreen when returning to the app.

    setKeepWindowStyleOnReturnFromOsPip(_ keep: Bool)

    Parameter name

    Type

    Description

    keep

    Bool

    Set the player playing state when returning to the app from OS PIP state.

    • true: Switch to the last playing state (pip, fullscreen) (default)

    • false: Always switch to full screen

    Sample code

    // Set to maintain the last playing state before switching to OS PIP.
    ShopLive.setKeepWindowStyleOnReturnFromOsPip(true)
    
    // Set to always switch to fullscreen when transitioning from OS PIP to the app.
    ShopLive.setKeepWindowStyleOnReturnFromOsPip(false)

    isKeepWindowStyleOnReturnFromOsPip

    Return the currently set value

    • true: Switch to the last playing state (pip, fullscreen) (default value)

    • false: Always switch to fullscreen.

    isKeepWindowStyleOnReturnFromOsPip() -> Bool

    Sample code

    print(ShopLive.isKeepWindowStyleOnReturnFromOsPip())


    ShopLiveCommonUser

    Authenticated user of Shoplive. Specify user information to authenticate the user.

    var user: ShopLiveCommonUser? { get set }
    public enum ShopliveCommonUserGender : String, CaseIterable {
        case female = "f"
        case male = "m"
        case neutral = "n"
    }
    public class ShopLiveCommonUser: NSObject {
        var userId: String?
        var name: String?
        var age: Int?
        var gender: ShopliveCommonUserGender?
        var userScore : Int?
        var custom : [String : Any]?

    In an Objective-C environment, use the ShopLiveCommonUserObjc object.



    authToken

    This is the security authentication token (JWT) string of the authenticated user using Shoplive. For user authentication, enter the authenticated user's security authentication token (JWT) string.

    var authToken: String? { get set }

    Sample code

    let generatedJWT = "eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2MTA1NzA1dfadsfasfadsfasdfwO"
    
    ShopLive.authToken = generatedJWT


    style

    This is the current Shoplive Player style.

    var style: ShopLive.PresentationStyle { get }
    public enum PresentationStyle: Int {
        case unknown
        case fullScreen
        case pip
    }

    Sample code

    print(ShopLive.style)


    playerMode

    This is the current mode of the Shoplive Player.

    var playerMode: ShopLive.PlayerMode { get }
    public enum PlayerMode: Int {
        case play
        case preview
        case none
    }

    enum PlayerMode

    Value

    Description

    play

    Playing video (rehearsal, live, replay) with Player running through play API.

    preview

    Preview playing with the player running using the preview API.

    none

    Player is not running.


    orientationMode

    This is the video aspect ratio information of the broadcast currently being played on the Shoplive Player.

    var orientationMode: ShopLive.VideoOrientation { get }
    public enum VideoOrientation: Int {
        case portrait
        case landscape
        case unknown
    }

    enum VideoOrientation

    Value

    Description

    portrait

    Broadcast in aspect ratio mode. (ratio example - 9:16)

    landscape

    Broadcast in landscape ratio mode. (ratio example - 16:9)

    unknown

    The mode is unknown, not broadcasting, or the broadcast information has not yet been updated with the SDK.


    playerWindow

    The instance of UIWindow where the Shoplive Player is currently being displayed.

    var playerWindow: ShopLiveWindow? { get }

    playerWindow.forceAddSubView

    This function is used when you want to insert a customer view on top of the ShopLive framework.

    In the case of a typical addSubView , the customer’s view may not be added according to ShopLive policy.

    ShopLive.playerWindow?.forceAddSubView({YOUR_VIEW})


    viewController

    The instance of the UIViewController where the Shoplive Player is currently being displayed.

    var viewController: ShopLiveViewController? { get }

    Sample code

    // Showing Alert on top of Shoplive Player 
    let alert = UIAlertController.init(title: "Alert on Player", message: nil, preferredStyle: .alert)
    alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
    
    ShopLive.viewController?.present(alert, animated: true, completion: nil)


    setVisibleStatusBar options

    You can hide the app's status bar when Shoplive Player is playing in full screen. In the case of inAppPip, the status bar is automatically displayed.

    setVisibleStatusBar

    setVisibleStatusBar(isVisible : Bool)

    Parameter name

    Type

    Description

    isVisible

    Bool

    Set whether to hide the status bar:

    • true: Show status bar (default value)

    • false: Hide status bar

    Sample code

    ShopLive.setVisibleStatusBar(isVisible : Bool)


    indicatorColor

    Sets the loading indicator color.

    var indicatorColor: UIColor { get set }

    Sample code

    ShopLive.indicatorColor = UIColor.red


    isSuccessCampaignJoin

    Check whether broadcast entry was successful.

    • Related callback: handleReceivedCommand - ON_SUCCESS_CAMPAIGN_JOIN

    isSuccessCampaignJoin() -> Bool

    Sample code

    print(ShopLive.isSuccessCampaignJoin())


    AutoResumeVideoOnCallEnded options

    Set the video to resume playing automatically when you return to the video after ending the call.

    setAutoResumeVideoOnCallEnded

    setAutoResumeVideoOnCallEnded(_ autoResume: Bool)

    Parameter name

    Type

    Description

    autoResume

    Bool

    After call ends, determine whether to autoplay the video:

    • true: Autoplay

    • false: Does not play automatically (default)

    Sample code

    ShopLive.setAutoResumeVideoOnCallEnded(true)

    isAutoResumeVideoOnCallEndedInterrupt due to call connection

    Returns the currently set value.

    • true: Autoplay after call ends

    • false: Video stops after call ends

    isAutoResumeVideoOnCallEnded() -> Bool

    Sample code

    print(ShopLive.isAutoResumeOnCallEnded())


    KeepPlayVideoOnHeadphoneUnplugged options

    setKeepPlayVideoOnHeadphoneUnplugged

    Indicates whether to keep playing video when the earphones (or headset) are disconnected.

    setKeepPlayVideoOnHeadphoneUnplugged(_ keepPlay: Bool)

    Parameter name

    Type

    Description

    keepPlay

    Bool

    When earphones (or headset) are disconnected, determines whether to continue to play the video:

    • true: Autoplay

    • false: Does not play automatically (default)

    Sample code

    ShopLive.setKeepPlayVideoOnHeadphoneUnplugged(true)

    isKeepPlayVideoOnHeadPhoneUnplugged

    Returns the currently set value.

    • true: Video continues to play

    • false: Video stops when headphone disconnected

    isKeepPlayVideoOnHeadPhoneUnplugged() -> Bool

    Sample code

    print(ShopLive.isKeepPlayVideoOnHeadPhoneUnplugged())


    NextActionOnHandleNavigation options

    Set the next action of Shoplive Player when the user selects a link such as a product, notice, or banner.

    public enum ActionType: Int {
        case PIP
        case KEEP
        case CLOSE
    }

    enum ActionType

    Value

    Description

    PIP

    PIP transition

    KEEP

    Keep the status

    CLOSE

    Terminate

    setNextActionOnHandleNavigation

    setNextActionOnHandleNavigation(actionType: ActionType)

    Parameter name

    Type

    Description

    actionType

    ActionType

    Next action of Shoplive Player when user selects link

    Sample code

    // transit to PIP 
    ShopLive.setNextActionOnHandleNavigation(.PIP)
    
    // keep current status
    ShopLive.setNextActionOnHandleNavigation(.KEEP)
    
    // terminate
    ShopLive.setNextActionOnHandleNavigation(.CLOSE)

    getNextActionTypeOnHandleNavigation

    Retrieve the current config of the NextActionTypeOnHandleNavigation.

    getNextActionTypeOnHandleNavigation() -> ActionType

    Sample code

    print(ShopLive.getNextActionTypeOnHandleNavigation())


    sendCommandMessage

    Delivers commands and payload to the server. You can pass commands and payloads in predefined formats. (Alternatively, you can define the command and payload in consultation with Shoplive.)

    @objc static func sendCommandMessage(command: String, payload: [String:Any]?)

    Parameter name

    Type

    Description

    command

    String

    The pre-defined command

    payload

    [String:Any]?

    The pre-defined payload

    Sample code

    let command: String = “COMMAND_NAME”
    var payload: [String : Any] = [:]
    
    payload[“Int_Data” : 1]
    payload[“String_Data” : “Sample_String”]
    
    ShopLive.sendCommandMessage(command: command, payload: payload)


    setMuteWhenPlayStart

    Set the sound to turn on or mute when you start Shoplive Player. (Default: Starts Shoplive Player with sound turned on.)

    @objc static func setMuteWhenPlayStart(_ mute: Bool)

    Parameter name

    Type

    Description

    mute

    Bool

    Determine whether to mute : Start with mute : Start with sound on

    • true: Start with mute

    • false: Start with sound on

    Sample code

    // Mute when player started
    ShopLive.setMuteWhenPlayStart(true)
    
    //Sound on when player started
    ShopLive.setMuteWhenPlayStart(false)


    setEnabledPictureInPicture

    Determines whether app support InAppPip and OSPip (Default : true )

    @objc static func setEnablePictureInPicture(isEnabled: Bool) 

    Sample code

    // Enable InAppPip and OSPIP 
    ShopLive.setEnabledPictureInPicture(isEnabled: true)
    
    // Disable InAppPip and OSPIP 
    ShopLive.setEnabledPictureInPicture(isEnabled: false)


    setEnableOSPictureInPicture

    Determines whether an app supports the OS’ PIP (Default : true)

    @objc static func setEnabledOSPictureInPictureMode(isEnabled: Bool) 

    Sample code

    // InAppPip(Enabled), OSPIP (Disabled)
    ShopLive.setEnabledPictureInPicture(isEnabled: true)
    ShopLive.setEnabledOSPictureInPicture(isEnabled: false)
    
    // InAppPip, OSPIP both enabled
    ShopLive.setEnabledPictureInPicture(isEnabled: true)
    ShopLive.setEnabledOSPictureInPicture(isEnabled: true)
    
    // InAppPip, OSPIP both disabled
    ShopLive.setEnabledPictureInPicture(isEnabled: false)
    ShopLive.setEnabledOSPictureInPicture(isEnabled: true)


    setPictureInPicturePadding

    Set PIP padding in PIP within the app. (top, left, right, bottom) (Default: top, left, right, bottom all set to 20) If an invalid value is set, it returns false and applies the default value.

    @objc static func setPictureInPicturePadding(padding: UIEdgeInsets) -> Bool

    Parameter name

    Type

    Description

    padding

    UIEdgeInsets

    Set padding values ​​such as top, left, right, bottom, etc.

    Sample code

    // left: 20 right: 30 bottom: 10 top: 10 
    
    let padding: UIEdgeInsets = .init(top: 10, left: 20, bottom: 10, right: 30)
    
    ShopLive.setPictureInPicturePadding(padding: padding)


    setPictureInPictureFloatingOffset

    Set the area where PIP can move in the PIP within the app. If an invalid value is set, it returns false and applies the default value.

    @objc static func setPictureInPictureFloatingOffset(offset: UIEdgeInsets) -> Bool

    Parameter name

    Type

    Description

    offset

    UIEdgeInsets

    Set the offset values ​​for top, left, right, and bottom.

    Sample code

    // left: 20, right: 30, bottom: 10, top: 10으로 offset 값 설정
    
    let offset: UIEdgeInsets = .init(top: 10, left: 20, bottom: 10, right: 30)
    
    ShopLive.setPictureInPictureFloatingOffset(offset: offset)


    setUsingLocalStorage

    Set whether to use the local storage save function.

    @objc static func setUsingLocalStorage(_ use: Bool)

    Parameter name

    Type

    Description

    use

    Bool

    Determines whether to use the local storage save function : Use the local storage save function : Disable the local storage save function

    • true: Use the local storage save function

    • false: Disable the local storage save function

    Sample code

    // Config to use local storage
    ShopLive.setUsingLocalStorage(true)
    
    // Config not to use local storage
    ShopLive.setUsingLocalStorage(false)


    setAppVersion

    Set the app version.

    • Even without calling the API, the version of the app is read by default and passed to the server.

    • Contact to Shoplive at ask@shoplive.cloud to use this feature.

    @objc static func setAppVersion(_ appVersion: String)

    Parameter name

    Type

    Description

    appVersion

    String

    The version of an app.

    Sample code

    let appVersion: String = “1.0.0”
    
    ShopLive.setAppVersion(appVersion)


    setMixWithOthers

    You can watch broadcasts with external audio.

    @objc static func setMixWithOthers(_ isMixAudio: Bool)

    Parameter name

    Type

    Description

    isMixAudio

    Bool

    • true: Watch broadcast with external audio

    • false: Player pauses when external audio is played (default: true)

    Sample code

    // Player pauses when external audio plays
    ShopLive.setMixWithOthers(false)
    
    // Player run together with external audio
    ShopLive.setMixWithOthers(true)


    useCloseButton

    You can activate the close button in Preview and PIP modes.

    @objc static func useCloseButton(_ use: Bool)

    Parameter name

    Type

    Description

    use

    Bool

    • true: Use the close button in Preview and PIP mode

    • false: Do not use the close button in Preview and PIP mode

    Sample code

    // Do not show close button on Preview and PIP
    ShopLive.useCloseButton(false)
    
    // Show close button on Preview and PIP
    ShopLive.useCloseButton(true)


    addParameter

    You can add custom data before launching the player.

    @objc static func addParameter(key: String, value: String)

    Parameter name

    Type

    Description

    key

    String

    A custom parameter key to apply additionally

    value

    String

    An additional custom parameter value to apply

    Sample code

    ShopLive.addParameter(key: "key", value: "value")


    removeParameter

    Before running the player, delete the custom data added by addParameter.

    @objc static func removeParameter(key: String)

    Parameter name

    Type

    Description

    key

    String

    A custom parameter key to delete


    Sample code

    ShopLive.removeParameter(key: "key")


    setUtmSource

    You can log UTM Source. Data can be checked at Data Insights.

    func setUtmSource(utmSource: String?)

    Parameter name

    Type

    Description

    utmSource

    String?

    It conveys where the inflow occurred.

    Sample code

    ShopLive.setUtmSource(“{utm_source}”)


    setUtmMedium

    You can log UTM Medium. Data can be checked at Data Insights.

    func setUtmMedium(utmMedium: String?)

    Parameter name

    Type

    Description

    utmMedium

    String?

    It conveys how the inflow occurred. Google recommends setting the medium parameter to refer to the marketing method that led to the inflow. (ex. cpc, banner, email, blog, social etc.)

    Sample code

    ShopLive.setUtmMedium(“{utm_medium}”)


    setUtmCampaign

    You can log UTM Campaigns. Data can be checked at Data Insights.

    func setUtmCampaign(utmCampaign: String?)

    Parameter name

    Type

    Description

    utmCampaign

    String?

    It tells you which advertising campaign the inflow occurred. It can be divided into Campaign Name, Campaign Term, and Campaign Content.

    Sample code

    ShopLive.setUtmCampaign(“{utm_campaign}”)


    setUtmContent

    You can log UTM Content. Data can be checked at Data Insights.

    func setUtmContent(utmContent: String?)

    Parameter name

    Type

    Description

    utmContent

    String?

    It conveys what kind of content the inflow was caused by a posting/advertisement. It is mainly used as a subdivision of campaign parameters.

    Sample code

    ShopLive.setUtmContent(“{utm_content}”)


    setResizeMode

    You can maintain the aspect ratio of the video. (Default:.CENTER_CROP)

    ShopLive.setResizeMode(option : ShopLiveResizeMode)