API: Common

    API: Common


    Article summary

    AccessKey setting

    Set the issued accessKey.

    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

    Property name

    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()


    Set UTM tag

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

    • ShopLiveCommon.setUtmSource(utmSource: String)

    • ShopLiveCommon.setUtmMedium(utmMedium: String)

    • ShopLiveCommon.setUtmCampaign(utmCampaign: String)

    • ShopLiveCommon.setUtmContent(utmContent: String)

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

    Parameter name

    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 all TextFont

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

    fun setTextTypeface(typeface: Typeface?)

    Parameter name

    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

    Parameter name

    Type

    Description

    context

    Context

    context

    Sample code

    ShopLiveCommon.getCacheDirectoryBytes(context: Context)


    Delete cache

    Delete Shoplive cache files

    fun deleteCacheFiles(parent: File): Boolean

    Parameter name

    Type

    Description

    parent

    File

    Remove files and directories.

    Sample code

    ShopLiveCommon.deleteCacheFiles(
        ShopLiveCommon.getCacheDirectory(
            applicationContext
        )
    )


    What's Next