API - Common

    API - Common


    Article summary

    AccessKey Setting

    Set the issued Access Key.

    ShopLiveCommon.setAccessKey(accessKey: String?)

    User Authentication

    JWT Authentication

    ShopLiveCommon.setUserJWT(jwt : String)

    Authenticate ShopLive JWT.

    ShopLiveCommon.setUserJWT(jwt : String)

    ShopLiveCommon.setUserJWT(accessKey : String, user: ShopLiveCommonUser)

    Authenticate with JWT token using user information. User data can be reviewed in Data Insights.

    ShopLiveCommonUser

    field

    type

    description

    userId

    String

    A value that ensures the uniqueness of a logged-in user (Required)

    name

    String?

    User name

    age

    Int?

    User age

    gender

    ShopLiveCommonUserGender?

    User gender

    userScore

    Int?

    Integers are available from -100 to 100.

    custom

    Map<String, Any>?

    Any data can be set up to 1KB.
    It allows checking the total/login viewers' data.

    ShopLiveCommon.setUserJWT(
      accessKey,
      ShopLiveCommonUser(userId).apply {
        name = "shoplive"
        age = 20
        gender = ShopLiveCommonUserGender.NEUTRAL
        userScore = 0
      }
    )

    Logged-in Check

    Determine if JWT login has occurred.

    if (ShopLiveCommon.isLoggedIn()) {
      // Do something
    }

    Clear Authentication Information

    Reset the configured authentication information.

    ShopLiveCommon.clearAuth()

    ShopLiveCommon.setUtmSource(utmSource: String)

    ShopLiveCommon.setUtmMedium(utmMedium: String)

    ShopLiveCommon.setUtmCampaign(utmCampaign: String)

    ShopLiveCommon.setUtmContent(utmContent: String)

    You can track UTM Source/Medium/Campaign/Content. The data can be reviewed in the Data Insights.

    fun setUtmSource(utmSource: String?)
    fun setUtmMedium(utmMedium: String?)
    fun setUtmCampaign(utmCampaign: String?)
    fun setUtmContent(utmContent: String?)

    field

    type

    description

    utmSource

    String?

    It provides information on where the incoming traffic originated.

    utmMedium

    String?

    It conveys how the incoming traffic was generated. Google recommends setting the medium parameter to denote the marketing method through which the traffic was induced, such as CPC, banner, email, blog, social, etc.

    utmCampaign

    String?

    It communicates which advertising campaign the incoming traffic originated from. This can be divided into Campaign Name, Term, and Content.

    utmContent

    String?

    It informs about the posting/advertisement that led to the incoming traffic, often utilized as a subcategory under the campaign parameter.

    Sample code

    ShopLiveCommon.setUtmSource(“{utm_source}”)
    ShopLiveCommon.setUtmMedium(“{utm_medium}”)
    ShopLiveCommon.setUtmCampaign(“{utm_campaign}”)
    ShopLiveCommon.setUtmContent(“{utm_content}”)

    Change Entire TextFont

    Change the font type of internal TextView, EditText, and Button.

    fun setTextTypeface(typeface: Typeface?)

    field

    type

    description

    typeface

    Typeface?

    Change fontType

    sample code

    ShopLiveCommon.setTextTypeface(if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        resources.getFont(R.font.nanumgothicbold)
    } else {
        ResourcesCompat.getFont(context, R.font.nanumgothicbold)
    })

    Check the size of the stored cache (bytes)

    Check the size (in bytes) of the cached directory for photos and videos (stored in the Shoplive cache directory).

    fun getCacheDirectoryBytes(context: Context): Long

    field

    type

    description

    context

    Context

    context

    Sample code

    ShopLiveCommon.getCacheDirectoryBytes(context: Context)

    Delete Cache

    Delete Shoplive cache files

    fun deleteCacheFiles(parent: File): Boolean

    field

    type

    description

    parent

    File

    You can remove files and directories.

    Sample code

    ShopLiveCommon.deleteCacheFiles(
        ShopLiveCommon.getCacheDirectory(
            applicationContext
        )
    )