messageCallback

    messageCallback


    Article summary

    When executing the init() function of the player provided by Shoplive, you can define pre-defined actions such as coupon download and product click by defining messageCallback, and you can also define custom actions for each customer.

    • For detailed instructions on connecting to the coupon function, please refer to Coupon Click Event.

    • For detailed instructions on controlling product click actions, please refer to Product Click Event.

    • For detailed instructions on defining the actions of users who are not logged in when accessing functions that require a login, please refer to Login Required Event.


    messageCallback definition

    <script type="text/javascript" src="https://static.shoplive.cloud/shoplive.js"></script>
    <script>
      var messageCallback = {
        SHOPLIVE_MESSAGE_CALLBACK_ACTION: function(payload) { // Change SHOPLIVE_MESSAGE_CALLBACK_ACTION to the desired action
          // Add payload processing logic
          // Write the code to handle the payload here
        }
      };
    
      cloud.shoplive.init({
        accessKey: 'YOUR ACCESS KEY HERE', 
        messageCallback: messageCallback
      });
    </script>


    messageCallback list

    Action

    Payload

    Description

    LOGIN_REQUIRED

    campaignKey (string)

    This event is called when the player requires login information while the player is running as a guest. (For example, if you click the chat button during live viewing as a guest) You can use it by inserting code to move to the login screen.

    DOWNLOAD_COUPON

    coupon (string)
    type(string)

    When a popup (banner, coupon, notice) is clicked, the value set together with the type is passed.
    Type: BANNER, COUPON, NOTICE

    CLICK_PRODUCT

    Goods

    This event is called when product information is clicked. If you need to perform additional processing, you can use it by receiving the URL for moving to the product detail page.
    Even if you do not process
    CLICK_PRODUCT separately, the player will move to the corresponding URL when you click the product.

    CLICK_PRODUCT_CART

    Goods

    This event is called when the shopping cart button in the product list is clicked. To be used for any additional processing that may be required, various product information is included in the payload.

    {
       "sku": string,
       "name": string,
       "brand": string,
       "url": string
    }

    LINK

    json object
    {"url": linkUrl}

    This event is called when the click event in the popup (banner, coupon, notice) is set to a link, or when the link at the top of the product list is clicked, along with the link address.
    If it is not implemented separately (override), the page itself will be moved in the web (exiting the current live page), and in the case of the app (SDK), it will enter PIP mode and NAVIGATION will be called.

    LINK_NEW_WINDOW

    json object
    {"url": linkUrl}

    This event is called when the click event in the popup (banner, coupon, notice) is set to a link (open a new window) and the user clicks the link, along with the link address.
    If it is not implemented separately (override), the web will open the linkUrl in a new window, and in the case of the app (SDK), it will enter PIP mode and NAVIGATION will be called.

    CLICK_SHARE_BTN

    json object

    This event is called when the share button is clicked. The following json object is included in the payload.

    {
       "campaignKey" : string,
       "shareUrl" : string
    }

    NOW_ONAIR_CHECKED

    PluginCampaign

    This event is called when the player modal has initiated to check whether the broadcast is On Air or not.

    ON_CLICK_CAMPAIGN_LIST_ITEM

    PluginCampaign

    When one of the Shoplive plugin broadcast lists is clicked.

    ON_PLAYER_MODAL_SHOWN

    PluginCampaign

    When the player modal UI is displayed on the screen.

    ON_PLAYER_MODAL_HIDDEN

    PluginCampaign

    When the player modal UI is closed and disappears from the screen.

    ON_CLICK_CLOSE_PLAYER_MODAL

    PluginCampaign

    When the user clicks the close button on the player modal UI.

    ON_LIVE_MINI_PREVIEW_SHOWN

    N/A

    When the live broadcast banner is displayed.

    ON_LIVE_MINI_PREVIEW_HIDDEN

    N/A

    When the live broadcast banner disappears from the screen.

    ON_CLICK_CLOSE_LIVE_MINI_PREVIEW

    N/A

    When the user clicks the close button on the live broadcast banner.

    ON_CLICK_BUY_BUTTON

    Goods

    When the 'Buy' button in the product list is clicked.

    ON_PRODUCT_LIST_SHOWN

    Array

    When the product list pop-up is displayed.