내용 x
하이브리드 연동
- 인쇄
내용
하이브리드 연동
- 인쇄
기사 요약
이 요약이 도움이 되었나요?
의견을 보내 주셔서 감사합니다.
라이브러리 추가
build.gradle
에 아래 코드를 추가하세요. app/build.gradle
에 통합된 라이브러리나 분할된 라이브러리를 추가하세요.
통합된 라이브러리
dependencies {
def shoplive_sdk_version = "1.5.16"
// Shoplive combined packaging
implementation "cloud.shoplive:shoplive-sdk-all:$shoplive_sdk_version" // live + short-form
}
분할된 라이브러리
dependencies {
def shoplive_sdk_version = "1.5.16"
def your_exoplayer_version = "2.19.1"
def your_media3_version = "1.4.1"
def shoplive_exoplayer_version = your_exoplayer_version + "." + "8"
def shoplive_media3_version = your_media3_version + "." + "8"
// Shoplive split packaging
implementation "cloud.shoplive:shoplive-common:$shoplive_sdk_version" // must required
implementation "cloud.shoplive:shoplive-exoplayer:$shoplive_exoplayer_version" // must required
// When using media3. Exoplayer will be deprecated soon.
// https://developer.android.com/guide/topics/media/media3/getting-started/migration-guide
// implementation "cloud.shoplive:shoplive-media3:$shoplive_media3_version"
implementation "cloud.shoplive:shoplive-network:$shoplive_sdk_version" // must required
implementation "cloud.shoplive:shoplive-short-form:$shoplive_sdk_version" // for short-form player
implementation "cloud.shoplive:shoplive-sdk-core:$shoplive_sdk_version" // for live player
}
Proguard Rule 추가
R8 Build를 하면 난독화 문제가 발생할 수 있습니다. 아래의 내용을 추가해주세요.
-keep public class cloud.shoplive.** { *; }
-dontwarn cloud.shoplive.**
-keep class org.json.** { *; }
-keep class com.google.gson.** { *; }
네이티브 코드 적용
고객사 웹 Activity
에 아래 코드를 추가하세요
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
webView.settings.domStorageEnabled = true // Required
webView.settings.javaScriptEnabled = true // Required
ShopLiveShortform.connectBridgeInterface(this, webView) // Required
webView.webViewClient = object : WebViewClient() {
...
// Required
override fun doUpdateVisitedHistory(view: WebView?, url: String?, isReload: Boolean) {
super.doUpdateVisitedHistory(view, url, isReload)
ShopLiveShortform.updateVisitedHistory(view, url, isReload)
}
...
}
// Optional
ShopLiveShortform.setHandler(object : ShopLiveShortformHandler() {
override fun getOnClickProductListener(): ShopLiveShortformProductListener {
return ShopLiveShortformProductListener { data, product ->
// Something landing customer
}
}
override fun getOnClickBannerListener(): ShopLiveShortformUrlListener {
return ShopLiveShortformUrlListener { data, url ->
// Something landing customer
}
}
override fun onEvent(command: String, payload: String?) {
// Do something
}
override fun onError(error: ShopLiveCommonError) {
// Do something
}
override fun onShare(activity: Activity, data: ShopLiveShortformData?, url: String?) {
// Do something
}
})
}