Handler

Shoplive Short-form에서 발생한 알림을 클라이언트에서 ShopLiveShortformReceiveHandlerDelegate 함수를 통해 전달받고 필요하게 처리합니다.

protocol ShopLiveShortformReceiveHandlerDelegate : AnyObject { @objc optional func handleShare(shareUrl: String) @objc optional func onError(error: Error) @objc optional func onEvent(command: String, payload: String?) @objc optional func onDidAppear() @objc optional func onDidDisAppear() } //핸들러 채택하기 class ViewController : ShopLiveShortformReceiveHandlerDelegate { override func viewDidLoad(){ super.viewDidLoad() ShopLiveShortform.ShortsReceiveInterface.setHandler(self) } }

onEvent(command: String, payload: String?)

Shoplive Short-form에서 발생하는 여러 가지 이벤트를 직접 핸들링할 수 있는 messageCallback 함수를 제공합니다.

Shortform Events


onError(error: Error)

Shoplive Short-form에서 발생하는 에러를 직접 핸들링할 수 있는 messageCallback 함수를 제공합니다.

ShortformError Type

typedescription
statusCode네트워크 응답 상태코드 에러
invalidConfigShort-form 설정 관련 에러
other기타 에러
public enum ShortformError: Error { case statusCode(Int) case invalidConfig case other(Error) var errorMessage: String { switch self { case .statusCode(let code): return "[Http status code : statusCode(\(code))] To use Shoplive Short-form, please contact ask@shoplive.cloud." case .invalidConfig: return "[Invalid config] To use Shoplive Short-form, please contact ask@shoplive.cloud." case .other(let error): return "[Other error] \(error.getErrorMsg())" } } }


handleShare(shareMetaData: ShopLiveShareMetaData)

Shoplive Short-form 에서 직접 공유하기 기능을 개발합니다.

ShopLiveMetaData

fieldtypedescription
shortsIdString?Shotr-form 고유의 아이디
shortsSrnString?Short-form 고유 정보를 담는 아이디
titleString?Short-form 제목 (og tag 용도)
descriptionsString?Short-form 설명 (og tag 용도)
thumbnailString?Short-form thumbnail (og tag 용도)
class ViewController : ShopLiveShortformReceiveHandlerDelegate { func handleShare(shareMetaData: ShopLiveShareMetaDatag) { //Do something } }

onDidAppear()

Shoplive Short-form의 Full type 화면의 열림 이벤트를 받아볼 수 있습니다.

class ViewController : ShopLiveShortformReceiveHandlerDelegate { func onDidAppear() { //ex) stop ListView player when entering Shortform detail builder?.disablePlayVideos() } }

onDidDisAppear()

Shoplive Short-form의 Full type 화면의 닫힘 이벤트를 받아볼 수 있습니다.

class ViewController : ShopLiveShortformReceiveHandlerDelegate { func onDidDisAppear(shareUrl: String) { //ex) play ListView players when ListView reappeared builder?.enablePlayVideos() } }

ShopLiveShortformNativeHandlerDelegate

Shoplive Short-form에서 발생한 알림을 클라이언트에서 ShopLiveShortformNativeHandlerDelegate 함수를 통해 전달받고 필요하게 처리합니다.

class ViewController : ShopLiveShortformNativeHandlerDelegate { func handleProductItem(shortsId : String, shortsSrn : String, product : Product){ } func handleProductBanner(shortsid : String, shortsSrn : String, scheme : String, shortsDetail : ShortsDetail){ } ) } ShopLiveShortform.ShortsReceiveInterface.setNativeHandler(self)

handleProductItem(shortsId : String, shortsSrn : String, product : Product)

Shoplive Short-form에서 직접 상품 클릭 기능을 개발합니다. 상품 생성하기

class ViewController : ShopLiveShortformNativeHandlerDelegate { func handleProductItem(shortsId : String, shortsSrn : String, product : Product) { //ex) Show preview when product is clicked with sku ShopLiveShortform.showPreview(requestData: ShopLiveShortformRelatedData(sku: product.sku)) } }

Product

fieldtypedescription
brandString?상품의 브랜드 정보
currencyString?상품의 통화
descriptionString?상품에 대한 설명
discountPriceDouble?상품의 할인 가격
discountRateDouble?상품의 할인율
imageUrlString?상품 이미지 URL
nameString?상품명
originalPriceDouble?상품의 정상 가격
productIdInt?상품 고유의 아이디. 상품 등록 시 자동으로 발급
showPriceBoolean상품의 보이는 가격
skuString?상품 고유의 SKU 정보
urlString?상품 상세 페이지의 URL

handleProductBanner(shortsid : String, shortsSrn : String, scheme : String, shortsDetail : ShortsDetail)

Shoplive Short-form에서 직접 배너 클릭 기능을 개발합니다. 배너 생성하기

class ViewController : ShopLiveShortformNativeHandlerDelegate { func handleProductBanner(shortsid : String, shortsSrn : String, scheme : String, shortsDetail : ShortsDetail) { { } }


Did this page help you?