API - Common

    API - Common


    기사 요약

    AccessKey 설정

    발급받은 accessKey를 설정합니다.

    ShopLiveCommon.setAccessKey(accessKey: String?)


    사용자 인증

    간편 인증

    ShopLiveCommon.setUser(user: ShopLiveCommonUser) 또는 ShopLiveCommon.setUser(accessKey: String, user: ShopLiveCommonUser)을 통해 사용자 정보를 저장합니다.

    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.setUser(
      accessKey,
      ShopLiveCommonUser(userId).apply {
        name = "shoplive"
        age = 20
        gender = ShopLiveCommonUserGender.NEUTRAL
        userScore = 0
      }
    )

    JWT 인증

    ShopLiveCommon.setAuthToken(jwt: String)을 통해 ShopLive JWT 인증합니다.

    ShopLiveCommon.setAuthToken(jwt : String)

    ShopLiveCommon.getAuthToken()을 통해 ShopLive에 있는 JWT 토큰을 가져옵니다. 만약 JWT 인증을 하지 않고 일반 인증을 했을 때도 생성된 토큰 정보를 가져옵니다.

    ShopLiveCommon.getAuthToken(): String?

    인증 정보 초기화

    설정된 인증 정보를 초기화합니다.

    ShopLiveCommon.clearAuth()

    로그인 확인

    JWT 로그인 여부를 파악합니다.

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


    마케팅 유입 경로 추적

    다음의 함수들을 통해 UTM 태그(Source/Medium/Campaign/Content)를 트래킹할 수 있습니다. 로깅된 정보는 데이터 인사이트에서 확인할 수 있습니다.

    • 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?

    해당 유입이 어디에서 발생하였는지 전달합니다.

    utmMedium

    String?

    해당 유입이 어떻게 발생하였는지 전달합니다. 구글은 medium 파라미터를 유입이 유도된 마케팅 방식을 지칭하도록 세팅하는 것을 권장하고 있습니다. (e.g. cpc, banner, email, blog, social etc.)

    utmCampaign

    String?

    어떤 광고의 캠페인으로 유입이 발생하였는지를 전달해줍니다. Campaign Name, Campaign Term, Campaign Content로 나눠서 만들 수 있습니다.

    utmContent

    String?

    해당 유입이 어떤 내용을 가진 포스팅/광고에 의해서 발생하였는지 전달합니다. 주로 campaign 파라미터의 하위 구분으로 자주 활용됩니다.

    Sample code

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


    모든 TextFont 변경

    내부 TextView, EditText, Button의 fontType을 변경합니다.

    fun setTextTypeface(typeface: Typeface?)

    Parameter name

    Type

    Description

    typeface

    Typeface?

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


    캐시 관리

    저장된 캐시 크기 확인 (bytes)

    사진, 영상 Cache 된 directory의 크기(bytes)를 확인합니다. (Shoplive cache directory에서 저장)

    fun getCacheDirectoryBytes(context: Context): Long

    Parameter name

    Type

    Description

    context

    Context

    context

    Sample code

    ShopLiveCommon.getCacheDirectoryBytes(context: Context)

    캐시 삭제

    Shoplive cache 파일들을 삭제합니다.

    fun deleteCacheFiles(parent: File): Boolean

    Parameter name

    Type

    Description

    parent

    File

    File, Directory를 제거할 수 있습니다.

    Sample code

    ShopLiveCommon.deleteCacheFiles(
        ShopLiveCommon.getCacheDirectory(
            applicationContext
        )
    )