API - Option
setShareScheme(_ scheme:, custom:)
공유하기를 선택(탭) 했을 때 시스템 공유 팝업으로 전달할 scheme
을 설정합니다.
custom
callback 함수를 설정하면 iOS 시스템 공유 팝업 대신 직접 커스텀 공유 팝업을 구현할 수 있습니다.
setShareScheme(_ scheme: String?, custom: (() -> Void)?)
매개변수 | 설명 |
---|---|
scheme | 공유할 scheme 또는 URL |
custom | 커스텀 공유 팝업 설정 |
샘플 코드
let scheme = "shoplive://live"
let scheme = "https://shoplive.cloud/live"
// iOS 시스템 공유 팝업
ShopLive.setShareScheme(scheme, custom: nil)
// 커스텀 공유 팝업
ShopLive.setShareScheme(scheme, custom: {
let alert = UIAlertController.init(title: "Use Custom Share", message: nil, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action) in
}))
ShopLive.viewController?.present(alert, animated: true, completion: nil)
})
- 적용 가이드
setChatViewFont(inputBoxFont:, sendButtonFont:)
채팅 폰트와 채팅 전송 버튼 폰트를 설정합니다.
setChatViewFont(inputBoxFont: UIFont, sendButtonFont: UIFont)
매개변수 | 설명 |
---|---|
inputBoxFont | 채팅 폰트 |
sendButtonFont | 채팅 전송 버튼 폰트 |
샘플 코드
/**
// 채팅 폰트 설정
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(images:)
영상 로딩 진행률을 이미지 애니메이션으로 설정합니다.
setLoadingAnimation(images: [UIImage])
매개변수 | 설명 |
---|---|
images | 이미지 애니메이션에 사용할 이미지 |
샘플 코드
var images: [UIImage] = []
for i in 1...11 {
images.append(.init(named: "loading\(i)")!)
}
ShopLive.setLoadingAnimation(images: images)
- 적용 가이드
pipPosition
PIP 모드를 시작할 때 기본 위치를 지정합니다.
처음 재생하고 PIP 모드를 시작하면 지정된 위치에서 시작됩니다.
(기본값: default)
public enum PipPosition: Int {
case topLeft
case topRight
case bottomLeft
case bottomRight
case `default`
}
매개변수 | 설명 |
---|---|
topLeft | 화면 좌상단 |
topRight | 화면 우상단 |
bottomLeft | 화면 좌하단 |
bottomRight | 화면 우하단 |
default | 마지막 위치 |
var pipPosition: ShopLive.PipPosition { get set }
샘플 코드
print(ShopLive.pipPosition)
pipScale
PIP 모드를 시작할 때 기본 크기입니다.
처음 재생 후 PIP 모드를 시작하면 지정된 크기로 시작됩니다.
기본값은 마지막으로 지정된 값입니다. 마지막으로 지정된 값이 없다면 기본값은 0.4배 크기입니다.
- 0.0 ~ 1.0 사이의 값을 입력하세요.
- 기기 화면의 너비(width) 기준으로 축소된 크기의 PIP 모드를 표시합니다.
- 재생되는 비디오의 PIP 화면 비율로 변경됩니다.
var pipScale: CGFloat { get set }
샘플 코드
print(ShopLive.pipScale)
startPictureInPicture(with: , scale: )
전체 화면 모드에서 PIP 모드로 전환합니다.
startPictureInPicture(with position: ShopLive.PipPosition, scale: CGFloat)
startPictureInPicture()
매개변수 | 설명 |
---|---|
position | PIP 모드가 시작될 때 위치 |
scale | 0.0 ~ 1.0 사이의 값 입력 |
샘플 코드
// 0.4배(기본값) 크기로 앱 내 PIP 모드 전환
ShopLive.startPictureInPicture()
// 화면 우하단에서 0.1배 크기로 앱 내 PIP 전환
ShopLive.startPictureInPicture(with: .bottomRight, scale: 0.1)
// 화면 좌상단에서 0.8배 크기로 앱 내 PIP 전환
ShopLive.startPictureInPicture(with: .topLeft, scale: 0.8)
크기 설정 예시
크기 | PIP 화면 | 크기 | PIP 화면 | 크기 | PIP 화면 |
---|---|---|---|---|---|
0.1 | 0.4 | 0.8 |
- 적용 가이드
stopPictureInPicture()
PIP 모드를 전체 화면 모드로 전환합니다.
stopPictureInPicture()
샘플 코드
ShopLive.stopPictureInPicture()
- 적용 가이드
hookNavigation(navigation: @escaping ((URL) -> Void))
상품 또는 배너를 선택할 때 매개변수에 설정한 custom
Callback 함수(매개변수로 입력한 navigation
)로 직접 이벤트를 받습니다.
hookNavigation(navigation: @escaping ((URL) -> Void))
매개변수 | 설명 |
---|---|
navigation | 상품 또는 배너를 선택할 때 호출되는 block
|
샘플 코드
ShopLive.hookNavigation { url in
// url: 선택한 상품 또는 배너에 설정된 상세 정보 URL
print("hookNavigation \(url)")
}
- 적용 가이드
setKeepAspectOnTabletPortrait(_ keep:)
태블릿 세로모드에서 Shoplive 화면의 비율을 설정합니다.
true
: 화면 비율 유지 (기본값)
false
: 화면 가득 채움
setKeepAspectOnTabletPortrait(_ keep: Bool)
매개변수 | 설명 |
---|---|
keep | 화면 비율 유지 여부 설정 |
샘플 코드
ShopLive.setKeepAspectOnTabletPortrait(true)
- 적용 가이드
user
Shoplive를 사용하는 인증된 사용자입니다.
사용자를 인증하기 위해 사용자 정보를 입력합니다.
var user: ShopLiveUser? { get set }
// 사용자 성별
public enum Gender : Int, Codable, CaseIterable {
case female = 1
case male = 2
case neutral = 3
case unknown = 0
}
public class ShopLiveUser: NSObject, Codable {
let name: String?
let gender: Gender?
let id: String?
let age: Int?
func add(_ params: [String: Any?])
func getParams() -> [String: String]
}
add(_ params:)
사용자에 매개변수를 추가합니다.
params
- Dictionary (key: value)
로 매개변수를 추가합니다.
- 이 옵션은 사전 협의 후에만 사용할 수 있습니다.
매개변수 | 설명 |
---|---|
userScore | 사용자 점수 |
샘플 코드
let user = ShopLiveUser(id: "id", name: "name", gender: Gender.male, age: 20)
user.add(["userScore": 40])
ShopLive.user = user
- 적용 가이드
authToken
Shoplive를 사용하는 인증된 사용자의 보안 인증토큰(JWT) string입니다.
사용자 인증을 위해 인증된 사용자의 보안 인증토큰(JWT) string을 입력합니다.
var authToken: String? { get set }
샘플 코드
let generatedJWT = "eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2MTA1NzA1dfadsfasfadsfasdfwO"
ShopLive.authToken = generatedJWT
- 적용 가이드
style
현재 Shoplive Player 스타일입니다.
var style: ShopLive.PresentationStyle { get }
public enum PresentationStyle: Int {
case unknown
case fullScreen
case pip
}
샘플 코드
print(ShopLive.style)
viewController
현재 Shoplive Player가 표시되고 있는 UIViewController의 인스턴스입니다.
var viewController: ShopLiveViewController? { get }
샘플 코드
// Shoplive Player 위에 Alert를 표시
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)
- 적용 가이드
indicatorColor
로딩 인디케이터 색을 설정합니다.
var indicatorColor: UIColor { get set }
샘플 코드
ShopLive.indicatorColor = UIColor.red
- 적용 가이드
isSuccessCampaignJoin() -> Bool
방송 진입 성공 여부를 확인합니다.
관련 Callback
: handleReceivedCommand - ON_SUCCESS_CAMPAIGN_JOIN
isSuccessCampaignJoin() -> Bool
샘플 코드
print(ShopLive.isSuccessCampaignJoin())
AutoResumeVideoOnCallEnded 옵션
통화 종료 후 영상으로 돌아왔을 때, 자동 재생이 되도록 설정합니다.
setAutoResumeVideoOnCallEnded(_ autoResume: Bool)
setAutoResumeVideoOnCallEnded(_ autoResume: Bool)
매개변수 | 설명 |
---|---|
autoResume | 통화 종료 후, 영상 자동 재생 |
샘플 코드
ShopLive.setAutoResumeVideoOnCallEnded(true)
- 적용 가이드
isAutoResumeVideoOnCallEnded() -> Bool
현재 설정된 값을 반환합니다.
true
: 통화 종료 후 자동재생
false
: 통화종료 후 영상 정지
isAutoResumeVideoOnCallEnded() -> Bool
샘플 코드
print(ShopLive.isAutoResumeOnCallEnded())
- 적용 가이드
KeepPlayVideoOnHeadphoneUnplugged 옵션
이어폰(또는 헤드셋) 연결이 끊겼을 때, 영상을 중지하지 않고 자동 재생이 되도록 설정합니다.
setKeepPlayVideoOnHeadphoneUnplugged(_ keepPlay: Bool)
이어폰(또는 헤드셋) 연결이 끊겼을 때, 영상을 중지하지 않고 자동 재생이 되도록 설정합니다.
setKeepPlayVideoOnHeadphoneUnplugged(_ keepPlay: Bool)
매개변수 | 설명 |
---|---|
keepPlay | 이어폰(또는 헤드셋) 연결이 끊겼을 때, 계속 영상 재생 |
샘플 코드
ShopLive.setKeepPlayVideoOnHeadphoneUnplugged(true)
- 적용 가이드
isKeepPlayVideoOnHeadPhoneUnplugged() -> Bool
현재 설정된 값을 반환합니다.
true
: 영상 계속 재생
false
: 연결이 끊기면 영상 정지
isKeepPlayVideoOnHeadPhoneUnplugged() -> Bool
샘플 코드
print(ShopLive.isKeepPlayVideoOnHeadPhoneUnplugged())
- 적용 가이드
NextActionOnHandleNavigation 옵션
사용자가 상품, 공지사항, 배너 등 링크를 선택하였을 때, Shoplive Player의 다음 동작을 설정합니다.
public enum ActionType: Int {
case PIP
case KEEP
case CLOSE
}
매개변수 | 설명 |
---|---|
PIP | PIP 전환 |
KEEP | 상태 유지 |
CLOSE | 종료 |
setNextActionOnHandleNavigation(actionType:)
setNextActionOnHandleNavigation(actionType: ActionType)
매개변수 | 설명 |
---|---|
actionType | 사용자의 링크 선택 시 Shoplive Player의 다음 동작 |
샘플 코드
// PIP 전환
ShopLive.setNextActionOnHandleNavigation(.PIP)
// 상태 유지
ShopLive.setNextActionOnHandleNavigation(.KEEP)
// 종료
ShopLive.setNextActionOnHandleNavigation(.CLOSE)
getNextActionTypeOnHandleNavigation() -> ActionType
사용자의 링크 선택 시 설정된 Shoplive Player의 다음 동작을 확인합니다.
getNextActionTypeOnHandleNavigation() -> ActionType
샘플 코드
print(ShopLive.getNextActionTypeOnHandleNavigation())
setEndpoint(_ url:)
Shoplive Player의 Web Landing 페이지가 아닌 특정 Landing 페이지 또는 URL에서 Shoplive 서비스를 사용해야 할 때 사용합니다.
예를 들어, 보안으로 인해 Shoplive Landing 페이지를 사용할 수 없는 경우, 특정 도메인으로 Landing 페이지를 생성할 수 있습니다.
※ Shoplive Player의 Web Landing 페이지는 Shoplive와 협의 후 적용할 수 있습니다.
setEndpoint(_ url: String?)
매개변수 | 설명 |
---|---|
url | Shoplive Player의 Web Landing url |
샘플 코드
// Shoplive Player의 Web Landing url 설정
ShopLive.setEndpoint("{Shoplive Player의 Web Landing url}")
// 설정 초기화
ShopLive.setEndpoint(nil)
sendCommandMessage
서버로 command와 payload를 전달합니다.
사전 정의된 형식의 command, payload 를 전달할 수 있습니다. (또는, Shoplive와 협의하여 command와 payload를 정의할 수 있습니다.)
@objc static func sendCommandMessage(command: String, payload: [String:Any]?)
매개변수 | 설명 |
---|---|
command | 사전 정의된 |
payload | 사전 정의된 |
샘플 코드
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(_ mute: Bool)
Shoplive Player를 시작할 때 사운드가 켜지도록 하거나 음소거하도록 설정합니다.
(기본값: 사운드가 켜진 상태로 Shoplive Player를 시작합니다.)
@objc static func setMuteWhenPlayStart(_ mute: Bool)
매개변수 | 설명 |
---|---|
mute | 음소거 설정 여부 |
샘플 코드
// Shoplive Player를 시작할 때 음소거하도록 설정
ShopLive.setMuteWhenPlayStart(true)
//Shoplive Player를 시작할 때 사운드가 켜지도록 설정
ShopLive.setMuteWhenPlayStart(false)
setPictureInPicturePadding(padding: UIEdgeInsets)
앱 내 PIP에서 PIP 패딩을 설정합니다. (top, left, right, bottom)
(기본값: top, left, right, bottom 모두 20으로 설정)
@objc static func setPictureInPicturePadding(padding: UIEdgeInsets)
매개변수 | 설명 |
---|---|
padding | Top, left, right, bottom 등 padding값을 설정합니다. |
샘플 코드
// 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(offset: UIEdgeInsets)
앱 내 PIP에서 PIP가 이동할 수 있는 영역을 설정합니다.
@objc static func setPictureInPictureFloatingOffset(offset: UIEdgeInsets)
매개변수 | 설명 |
---|---|
offset | top, left, right, bottom의 offset 값을 설정합니다. |
샘플 코드
// 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(_ use: Bool)
로컬 스토리지 저장 기능 사용 여부를 설정합니다.
@objc static func setUsingLocalStorage(_ use: Bool)
매개변수 | 설명 |
---|---|
use | 로컬 스토리지 저장 기능 사용 여부 |
샘플 코드
// 로컬 스토리지 저장 기능을 사용하도록 설정
ShopLive.setUsingLocalStorage(true)
// 로컬 스토리지 저장 기능을 사용하지 않도록 설정
ShopLive.setUsingLocalStorage(false)
setAppVersion(_ appVersion: String)
앱 버전을 설정합니다.
API를 호출하지 않아도 기본값으로 앱 버전을 읽고 서버로 전달됩니다.
이 기능을 사용하려면 Shoplive 담당자에게 문의하세요.
@objc static func setAppVersion(_ appVersion: String)
매개변수 | 설명 |
---|---|
appVersion | 앱 버전 |
샘플 코드
let appVersion: String = “1.0.0”
ShopLive.setAppVersion(appVersion)
Updated 3 months ago