Step5. Coupons

    Step5. Coupons


    Article summary

    This is a guide to integrate the coupon popup feature into the Shoplive Player SDK.


    LINK / LINK (New window)

    This is the method for integrating coupons when the coupon click event is set to LINK or LINK (New window).

    handleNavigation

    This is the callback function that is called when the coupon is clicked. It receives a URL, which can then be implemented according to the logic of the client's app.

    Parameter name

    Type

    Description

    url

    String

    link url

    Sample code

    override fun handleNavigation(context: Context, url: String) {
      
      val intent = Intent(this@YourActivity, WebViewActivity::class.java)
      intent.putExtra("url", url)
      startActivity(intent)
    }


    Download coupon

    This is the method for integrating coupons when the coupon click event is selected as Download coupon.

    handleDownloadCoupon

    This is the callback function that is called when the coupon is clicked. It receives the coupon ID, which can then be implemented according to the logic of the client's app.

    Parameter name

    Type

    Description

    couponId

    String

    Coupoin ID

    callback

    ShopLiveHanderCallback

    This is an object used to convey the results of coupon issuance to Shoplive after issuing a coupon to a user.

    Sample code

    override fun handleDownloadCoupon(
            context: Context,
            couponId: String,
            callback: ShopLiveHandlerCallback
    ) {
        // You can check parameter of couponResult from below links to API Reference
        callback.couponResult(
            isDownloadSuccess = true, 
            message = "Coupon download success!", 
            couponStatus = ShopLive.CouponPopupStatus.HIDE, 
            alertType = ShopLive.CouponPopupResultAlertType.ALERT
        )
    }


    User define

    This is the method for integrating coupons when the coupon click event is selected as User define. Clients can define the necessary information in JSON format and add it to the Payload object.

    handleCustomAction

    This is the callback function that is called when the coupon is clicked. It receives the defined information, which can then be implemented according to the logic of the client's app.

    Parameter name

    Type

    Description

    id

    String

    Unique id of the popup

    type

    String

    Type of popup (COUPON, BANNER, NOTICE)

    payload

    String

    User defined payload data

    callback

    ShopLiveHanderCallback

    This is an object used to convey the results of coupon issuance to Shoplive after issuing a coupon to a user.

    Sample code

    override fun handleCustomAction(
            context: Context, 
            id: String, 
            type: String, 
            payload: String,
            callback: ShopLiveHandlerCallback) {
         
        // Check the parameters of customActionResult at the API Reference link below.
        callback.customActionResult(
            isSuccess = true, 
            message = "success!", 
            couponStatus = ShopLive.CouponPopupStatus.HIDE, 
            alertType = ShopLive.CouponPopupResultAlertType.ALERT
        )
    }