API - Common

인증, 공통 유틸 함수

AccessKey 설정

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

ShopLiveCommon.setAccessKey(accessKey: String?)

JWT 인증

ShopLiveCommon.setUserJWT(jwt : String)

ShopLive JWT인증합니다.

ShopLiveCommon.setUserJWT(jwt : String)

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

User정보를 사용하여 JWT token인증을 합니다. 사용자 데이터는 데이터 인사이트에서 확인할 수 있습니다.

ShopLiveCommonUser

fieldtypedescription
userIdString로그인 사용자 아이디 (Required)
nameString?이름
ageInt?나이
genderShopLiveCommonUserGender?성별
userScoreInt?사용자 등급을 세팅하면 등급에 따른 입장 제한, 이벤트 추첨 제한 등의 기준으로 사용할 수 있습니다.
-100~100까지 설정할 수 있습니다.
customMap<String, Any>?별도로 제공하지 않는 값을 추가할 수 있습니다.
ShopLiveCommon.setUserJWT(
  accessKey,
  ShopLiveCommonUser(userId).apply {
    name = "shoplive"
    age = 20
    gender = ShopLiveCommonUserGender.NEUTRAL
    userScore = 0
  }
)

로그인 확인

JWT로그인을 했는지 유무를 파악합니다.

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

인증 정보 초기화

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

ShopLiveCommon.clearAuth()

AdId 설정

AdId를 설정하여 통계를 측정합니다.

ShopLiveCommon.setAdId(adId : String?)

모든 TextFont 변경

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

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에서 저장)

ShopLiveCommon.getCacheDirectoryBytes(context: Context)

캐시 삭제

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

ShopLiveCommon.deleteCacheFiles(context: Context)