When a coupon is selected (tapped) in Shoplive, the coupon information is transmitted to the client. The client's coupon processing result is then communicated back to the Shoplive Android SDK through a callback, which is used to set the coupon status in the Shoplive Player.
fun handleDownloadCoupon(context: Context, couponId: String, callback: ShopLiveHandlerCallback)
parameter
explanation
context
Context
couponId
Selected coupon ID
callback
ShopLive will notify you when the coupon is processed.callback
callback ShopLiveHandlerCallback.couponResult
When the coupon download is completed, it is called to deliver information regarding the success or failure of the result, along with any relevant messages.
To communicate the success or failure status, as well as any associated messages, when the customAction processing is completed, you call this to send those messages.
/**
* @param isSuccess - true: 성공, false: 실패
* @param message - 성공 또는 실패 메시지
* @param couponStatus - SHOW: 재활성, HIDE: 숨김, KEEP: 상태 유지
* @param alertType - ALERT: 팝업, TOAST: 메시지
* */
fun customActionResult(
isSuccess: Boolean,
message: String?,
couponStatus: ShopLive.CouponPopupStatu,
alertType: ShopLive.CouponPopupResultAlertType?) {}
sample code
private val handler = object : ShopLiveHandler() {
override fun handleCustomAction(
context: Context,
id: String,
type: String,
payload: JSONObject,
callback: ShopLiveHandlerCallback
) {
val builder: AlertDialog.Builder = Builder(context)
builder.setTitle("커스텀 액션(팝업)")
builder.setMessage("id: $id" + " type: " + R.attr.type + " payload: " + payload.toString())
builder.setPositiveButton("성공") { dialog, which ->
// 성공했을 때 콜백 설정
callback.couponResult(
true,
"Custom action(Popup) 처리가 성공하였습니다.",
ShopLive.CouponPopupStatus.HIDE,
ShopLive.CouponPopupResultAlertType.TOAST
)
}
builder.setNegativeButton("실패") { dialog, which ->
// 실패했을 때 콜백 설정
callback.couponResult(
false,
"Custom action(Popup) 처리가 실패하였습니다.",
ShopLive.CouponPopupStatus.SHOW,
ShopLive.CouponPopupResultAlertType.ALERT
)
}
val dialog: Dialog = builder.create()
dialog.show()
}
}
When you choose to share during a live broadcast, it is the Handler. To implement it directly without using the Android Share Sheet, you must override it.
fun handleShare(context: Context, shareUrl: String) {}
parameter
explanation
context
Context
shareUrl
URL or scheme to share
sample code
private val handler = object : ShopLiveHandler() {
override fun handleShare(context: Context?, shareUrl: String?) {
Toast.makeText(context, "url=$shareUrl", Toast.LENGTH_SHORT).show()
}
}
private val handler = object : ShopLiveHandler() {
override fun onSetUserName(jsonObject: JSONObject?) {
Log.d(TAG, "onSetUserName >> $jsonObject")
}
}
ShopLiveHandler.handlePreview
When you select the Shoplive preview screen, it's a Handler.
Choosing the preview screen will lead you to the corresponding broadcast (default behavior). To implement it directly without entering the broadcast, you must override it.
However, please note that this event is only delivered when using the preview screen provided as an overlay on top of other apps. In the OS PIP (Picture-in-Picture) mode, the preview event won't be delivered, and it will automatically enter full-screen broadcast mode.
fun handlePreview(context: Context, campaignKey: String) {}
parameter
explanation
context
Context
campaignKey
Campaign (broadcast) key
sample code
private val handler = object : ShopLiveHandler() {
override fun handlePreview(context: Context, campaignKey: String) {
Log.d(TAG, "campaignKey=$campaignKey")
}
}