Step6. Handling product clicks

    Step6. Handling product clicks


    Article summary

    When a product is selected or a shopping cart is chosen on the Shoplive Player screen, the event that occurs and the selected information are transmitted to the client by the Shoplive iOS SDK.


    Use the Handler to deliver an event

    CLICK_PRODUCT_DETAIL

    When a product is selected from the product list on the Shoplive Player screen, the Shoplive iOS SDK uses the handleReceivedCommand function to transmit the selected product information to the client.

    func handleReceivedCommand(_ command: String, with payload: Any?) {
         // print("handleReceivedCommand: \(command) payload: \(payload)")
         // command: CLICK_PRODUCT_DETAIL
    }

    CLICK_PRODUCT_CART

    When the shopping cart button is clicked on the product list on the Shoplive Player screen, the Shoplive iOS SDK uses the handleReceivedCommand function to transmit the shopping cart information to the client.

    func handleReceivedCommand(_ command: String, with payload: Any?) {
         // print("handleReceivedCommand: \(command) payload: \(payload)")
         // command: CLICK_PRODUCT_CART                        
    }

    handleNavigation

    When a product, banner, or similar item is selected on the live broadcast screen, the Shoplive iOS SDK uses the handleNavigation function to transmit the URL information of the selected item to the client.

    func handleNavigation(with url: URL) {
         // URL: URL of selected product or banner 
         print("handleNavigation \(url)")
    }


    Dispatch events using API

    hookNavigation

    By using the hookNavigation, when a user selects a product or banner, the event is directly received through the block set in the parameter.

    ShopLive.hookNavigation { url in
        // url: URL of selected product or banner
        print("hookNavigation \(url)")
    }