Handler

    Handler


    기사 요약

    숏폼에서 발생한 알림을 클라이언트에서 ShopLiveShortformReceiveHandlerDelegate 함수를 통해 전달받고 필요에 따라 처리합니다.

    protocol ShopLiveShortformReceiveHandlerDelegate : AnyObject  {
        @objc optional func handleShare(shareMetadata : ShopLiveShareMetaData)
        @objc optional func onError(error: Error)
        @objc optional func onEvent(command: String, payload: String?)
        @objc optional func onDidDisAppear()
        @objc optional func onDidAppear()
        @objc optional func handleProductItem(shortsId : String, shortsSrn : String, product : ProductData)
        @objc optional func handleProductBanner(shortsId : String, shortsSrn : String, scheme : String, shortsDetail : ShortsDetailData)
    }
    
    // 핸들러 채택하기
    
    
    class ViewController : ShopLiveShortformReceiveHandlerDelegate { 
      
      override func viewDidLoad(){
        super.viewDidLoad()
        ShopLiveShortform.Delegate.setDelegate(self)
      }
      
    }


    onEvent

    onEvent(command: String, payload: String?)를 통해 숏폼에서 발생하는 여러 가지 이벤트를 직접 핸들링할 수 있는 messageCallback 함수를 제공합니다.


    onError

    onError(error: Error)를 통해 숏폼에서 발생하는 에러를 직접 핸들링할 수 있는 messageCallback 함수를 제공합니다.

    ShopLiveCommonError

    Property name

    Type

    Description

    code

    Int

    Shoplive 지정 에러코드

    message

    String?

    에러 메시지

    error

    Error?

    에러 원문

    class ViewController : UIViewController, ShopLiveShortformReceiveHandlerDelegate { 
    	func onError(error : Error) {
      	if let error = error as? ShopLiveCommonError {
        	if let code = error.code { 
          	//do something
          }
          if let message = error.message {
          	//do something
          }
          if let error = error.error { 
          	//do something
          }
        }
      }
    }


    handleShare

    handleShare(shareMetaData: ShopLiveShareMetaData)를 통해 숏폼에서 직접 공유하기 기능을 개발합니다.

    ShopLiveMetaData

    Property name

    Type

    Description

    shortsId

    String?

    숏폼 고유 ID

    shortsSrn

    String?

    숏폼의 고유 정보를 담는 ID

    title

    String?

    숏폼 제목 (og tag 용도)

    descriptions

    String?

    숏폼 설명 (og tag 용도)

    thumbnail

    String?

    숏폼 썸네일 (og tag 용도)


    onDidAppear

    onDidAppear()를 통해 숏폼 Full type 화면의 열림 이벤트를 받아볼 수 있습니다.

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


    onDidDisAppear

    onDidDisAppear()를 통해 숏폼 Full type 화면의 닫힘 이벤트를 받아볼 수 있습니다.

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


    ShopLiveShortformDetailHandlerDelegate

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

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

    handleProductItem

    handleProductItem(shortsId: String, shortsSrn: String, product: Product)를 통해 숏폼에서 직접 상품 클릭 기능을 개발합니다.

    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

    Property name

    Type

    Description

    brand

    String?

    상품의 브랜드 정보

    currency

    String?

    상품의 통화

    description

    String?

    상품에 대한 설명

    discountPrice

    Double?

    상품의 할인 가격

    discountRate

    Double?

    상품의 할인율

    imageUrl

    String?

    상품 이미지 URL

    name

    String?

    상품명

    originalPrice

    Double?

    상품의 정상 가격

    productId

    String?

    상품 고유의 아이디. 상품 등록 시 자동으로 발급

    showPrice

    Boolean

    상품의 보이는 가격

    sku

    String?

    상품 고유의 SKU 정보

    url

    String?

    상품 상세 페이지의 URL

    handleProductBanner

    handleProductBanner(shortsId: String, shortsSrn: String, scheme: String, shortsDetail: ShortsDetail)를 통해 숏폼에서 직접 배너 클릭 기능을 개발합니다.

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