AccessKey設定
発行されたAccessKeyを設定します。
ShopLiveCommon.setAccessKey(accessKey: String?)
ユーザー認証
簡易認証
ShopLiveCommon.setUserJWT(accessKey : String, user: ShopLiveCommonUser)
ユーザー情報を保存します。詳しくは ユーザー 認証 ガイドを参照してください。
ShopLiveCommonUser
フィールド | タイプ | 説明 |
---|
userId | String! | ログインしたユーザーのユニークID (必須) |
name | String? | ユーザー名 |
age | Int? | ユーザーの年齢 |
gender | ShopLiveCommonUserGender? | ユーザーの性別 |
userScore | Int? | -100 から 100 の整数を使用できます。 |
custom | Map<String, Any>? | 任意のデータを1KBまで設定できます。 合計/ログイン視聴者のデータを確認できます。 |
ShopLiveCommon.setUserJWT(
accessKey,
ShopLiveCommonUser(userId).apply {
name = "shoplive"
age = 20
gender = ShopLiveCommonUserGender.NEUTRAL
userScore = 0
}
)
JWT認証
ShopLiveCommon.setUserJWT(jwt : String)
ShopLive JWT認証
ShopLiveCommon.setUserJWT(jwt : String)
認証情報の初期化
設定した認証情報を初期化します。
ShopLiveCommon.clearAuth()
ログイン認証
JWT ログインし ているかどうかを判別します。
if (ShopLiveCommon.isLoggedIn()) {
// Do something
}
マーケティング流入経路の追跡
ShopLiveCommon.setUtmSource(utmSource: String)
ShopLiveCommon.setUtmMedium(utmMedium: String)
ShopLiveCommon.setUtmCampaign(utmCampaign: String)
ShopLiveCommon.setUtmContent(utmContent: String)
UTM タグ(参照元 / メディア / キャンペーン / コンテンツ)をトラッキングできます。ログに記録された情報は、Shopliveのデータインサイトで確認することができます。
fun setUtmSource(utmSource: String?)
fun setUtmMedium(utmMedium: String?)
fun setUtmCampaign(utmCampaign: String?)
fun setUtmContent(utmContent: String?)
フィールド | タイプ | 説明 |
---|
utmSource | String? | そのトラフィックが発生したソースを表します。 |
utmMedium | String? | そのトラフィックが発生したメディアを表します。Googleは、流入につながったマーケティング手法を参照するためにmediumパラメータを設定することを推奨しています。(例:CPC、バナー、メール、ブログ、SNSなど) |
utmCampaign | String? | そのトラフィックが発生したキャンペーンを表します。キャンペーン名、キャンペーン期間、キャンペーンコンテンツなど判別することができます。 |
utmContent | String? | そのトラフィックが発生したコンテンツ(投稿、広告など)を表します。キャンペーンパラメータを細分化するために使用することができます。 |
サンプルコード
ShopLiveCommon.setUtmSource(“{utm_source}”)
ShopLiveCommon.setUtmMedium(“{utm_medium}”)
ShopLiveCommon.setUtmCampaign(“{utm_campaign}”)
ShopLiveCommon.setUtmContent(“{utm_content}”)
すべてのテキストフォントを変更する
内部の TextView、EditText、および Button の fontType を変更します。
fun setTextTypeface(typeface: Typeface?)
フィールド | タイプ | 説明 |
---|
typeface | Typeface? | 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) を確認する
写真とビデオのキャッシュされたディレクトリのサイズ(bytes)を確認します。(Shopliveキャッシュディレクトリに保存)
fun getCacheDirectoryBytes(context: Context): Long
フィールド | タイプ | 説明 |
---|
context | Context | context |
サンプルコード
ShopLiveCommon.getCacheDirectoryBytes(context: Context)
キャッシュのクリア
Shopliveキャッシュファイルを削除します。
fun deleteCacheFiles(parent: File): Boolean
フィールド | タイプ | 説明 |
---|
parent | File | ファイル、ディレクトリ。 |
サンプルコード
ShopLiveCommon.deleteCacheFiles(
ShopLiveCommon.getCacheDirectory(
applicationContext
)
)