Event handler

    Event handler


    Article summary

    Notification raised by Shoplive Shortform in the Handler clientIt is passed through a function and handles it as needed.

    ShopLiveShortform.setHandler(object : ShopLiveShortformHandler() {
    	override fun getOnClickProductListener(): ShopLiveShortformProductListener {
    	    return ShopLiveShortformProductListener { context, data, product ->
    	        // Something landing customer
        	}
    	}
    
    	override fun getOnClickBannerListener(): ShopLiveShortformUrlListener {
        	return ShopLiveShortformUrlListener { context, data, url ->
            	// Something landing customer
    	    }
    	}
    
    	override fun onEvent(context: Context, messenger: ShopLiveShortformMessageListener?, command: String, payload: Map<String, Any?>) {
    		// Do something
    	}
            
    	override fun onError(context: Context, error: ShopLiveCommonError) {
    		// Do something
    	}
            
    	override fun onShare(context: Context, data: ShopLiveShortformShareData) {
    		// Do something
    	}
      
    	override fun onCreate() {
    		// Do something
    	}
      
    	override fun onDestroy() {
    		// Do something
    	}
    
        open fun onShortsAttached(data: ShopLiveShortformData) {
    		// Do something
        }
    
        open fun onShortsDetached(data: ShopLiveShortformData) {
    		// Do something
        }
    })


    onEvent

    onEvent(context: Context, messenger: ShopLiveShortformMessageListener?, command: String, payload: Map<String, Any?>Shoplive provides a messageCallback function that allows you to handle a number of events directly from the Shortform.

    ShopLiveShortformMessageListener

    Property

    Type

    Description

    view

    View

    UI Component

    sendCommandMessage

    You can pass a specific event to a notification function that occurred in a view.

    fun onEvent(context: Context, messenger: ShopLiveShortformMessageListener?, command: String, payload: Map<String, Any?>) {
        messenger?.sendCommandMessage("SET_CUSTOM_SHORTFORM", payload = "YOUR_PAYLOAD")
    }


    onError

    onError(context: Context, error: ShopLiveCommonError) provides a messageCallback function that allows you to directly handle errors that occur in Shoplive Shortform.

    ShopLiveCommonError

    Property

    Type

    Description

    code

    Int

    ShopLiveCommonErrorCode

    message

    String?

    Error Messages

    cause

    Throwable?

    Error Causes


    onShare

    onShare(context: Context, data: ShopLiveShortformShareData)Develop a sharing feature directly from Shoplive Shortform.

    ShopLiveShortformShareData

    Property

    Type

    Description

    shortsId

    String?

    Shotrform's unique username

    srn

    String?

    An ID that contains Shortform-specific information.

    title

    String?

    Shortform Title (for og tag)

    description

    String?

    Shortform description (for og tag)

    thumbnail

    String?

    Shortform thumbnail (for og tag)


    onCreate

    onCreate()allows you to develop the functionality you need to enter the Shoplive Shortform detail screen.


    onDestroy

    onDestroy()You can develop the features you need to advance from the Shoplive Shortform detail screen.


    onShortsAttached

    onShortsAttached(data: ShopLiveShortformData)This allows you to develop the functionality you need when you are in the Shoplive Shortform with each of your shorts attached.


    onShortsDetached

    onShortsDetached(data: ShopLiveShortformData)Shoplive allows you to develop the features you need when each of your shorts detach state in the Shortform.


    ShopLiveShortformProductListener

    onClick

    onClick(context: Context, data: ShopLiveShortformIdentifier?, product: ShopLiveShortformProductData)Through Shoplive we develop the ability to click products directly in Shortform. 상품 생성하기 refer to the guide.

    ShopLiveShortformIdentifier

    Property

    Type

    Description

    shortsId

    String?

    Shotrform's unique username

    srn

    String?

    An ID that contains Shortform-specific information.

    ShopLiveShortformProductData

    Property

    Type

    Description

    brand

    String?

    Brand information of the product

    currency

    String?

    Currency of the commodity

    description

    String?

    Description of the product

    discountPrice

    Double?

    Discounted price of the product

    discountRate

    Double?

    Discount rate of the product

    imageUrl

    String?

    Product image URL

    name

    String?

    Product Name

    originalPrice

    Double?

    The regular price of the product

    productId

    Long?

    A unique ID for the product. Automatically issued at the time of product registration

    showPrice

    Boolean

    The visible price of the goods

    sku

    String?

    Product-specific SKU information

    url

    String?

    The URL of the product detail page


    ShopLiveShortformUrlListener

    onClick

    onClick(context: Context, data: ShopLiveShortformIdentifier?, url: String)Through Shoplive you develop banner clicks directly in Shortform. Creating a Banner within a Short-form Video refer to the guide.

    ShopLiveShortformIdentifier

    Property

    Type

    Description

    shortsId

    String?

    Shotrform's unique username

    srn

    String?

    An ID that contains Shortform-specific information.