From 21d6bfe19be6f19b65c848ee11148d4a68c7bf57 Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Wed, 12 Jun 2024 18:12:22 +0200 Subject: [PATCH] refactor: Fix values and constants in SDK and change instance SDK in other classes --- .../src/main/kotlin/com/personalizatio/SDK.kt | 212 ++++++++++++------ .../stories/viewAdapters/ProductsAdapter.kt | 13 +- .../stories/views/StoriesView.kt | 14 +- .../stories/views/StoryDialog.kt | 27 ++- .../personalizatio/stories/views/StoryView.kt | 22 +- .../stories/views/storyItem/StoryItemView.kt | 14 +- .../rees46/kotlin/com/rees46/sdk/REES46.kt | 21 +- 7 files changed, 220 insertions(+), 103 deletions(-) diff --git a/personalizatio-sdk/src/main/kotlin/com/personalizatio/SDK.kt b/personalizatio-sdk/src/main/kotlin/com/personalizatio/SDK.kt index 7b2d88f4..b202a461 100644 --- a/personalizatio-sdk/src/main/kotlin/com/personalizatio/SDK.kt +++ b/personalizatio-sdk/src/main/kotlin/com/personalizatio/SDK.kt @@ -31,44 +31,46 @@ import org.json.JSONException import org.json.JSONObject open class SDK { - private lateinit var context: Context - private var did: String? = null - private var seance: String? = null - private var onMessageListener: OnMessageListener? = null - - val tag: String - get() = TAG - @Volatile - private var initialized = false - - @Volatile - private var attempt = 0 - private val queue: MutableList = Collections.synchronizedList(ArrayList()) - private var search: Search? = null + private lateinit var preferencesKey: String + private lateinit var context: Context private lateinit var segment: String private lateinit var source: Source private lateinit var shopId: String private lateinit var stream: String - private lateinit var preferencesKey: String - private var lastRecommendedBy: RecommendedBy? = null + private lateinit var api: Api - private lateinit var api : Api + private val queue: MutableList = Collections.synchronizedList(ArrayList()) + private var onMessageListener: OnMessageListener? = null + private var lastRecommendedBy: RecommendedBy? = null + private var seance: String? = null + private var search: Search? = null + private var did: String? = null + private var initialized = false + private var attempt = 0 /** * @param shopId Shop key */ - fun initialize(context: Context, shopId: String, apiUrl: String, tag: String, preferencesKey: String, stream: String) { + fun initialize( + context: Context, + shopId: String, + apiUrl: String, + preferencesKey: String, + stream: String + ) { this.api = Api.getApi(apiUrl) this.context = context this.shopId = shopId this.stream = stream this.preferencesKey = preferencesKey - TAG = tag //Инициализируем сегмент - segment = prefs().getString("$preferencesKey.segment", arrayOf("A", "B")[Math.round(Math.random()).toInt()]).toString() + segment = prefs().getString( + "$preferencesKey.segment", + arrayOf("A", "B")[Math.round(Math.random()).toInt()] + ).toString() source = Source.createSource(prefs()) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { @@ -77,7 +79,13 @@ open class SDK { val channelName = context.getString(R.string.notification_channel_name) val notificationManager = context.getSystemService(NotificationManager::class.java) if (notificationManager != null) { - notificationManager.createNotificationChannel(NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_LOW)) + notificationManager.createNotificationChannel( + NotificationChannel( + channelId, + channelName, + NotificationManager.IMPORTANCE_LOW + ) + ) } else { error("NotificationManager not allowed") } @@ -191,8 +199,9 @@ open class SDK { seance = alphanumeric(10) } updateSidActivity() - debug("Device ID: " + did + ", seance: " + seance + ", last act: " - + Timestamp(prefs().getLong(SID_LAST_ACT_FIELD, 0)) + debug( + "Device ID: " + did + ", seance: " + seance + ", last act: " + + Timestamp(prefs().getLong(SID_LAST_ACT_FIELD, 0)) ) //Seach @@ -368,7 +377,12 @@ open class SDK { * @param params Дополнительные параметры к запросу * @param listener v */ - fun search(query: String, type: SearchParams.TYPE, params: SearchParams, listener: OnApiCallbackListener) { + fun search( + query: String, + type: SearchParams.TYPE, + params: SearchParams, + listener: OnApiCallbackListener + ) { if (search != null) { params.put(InternalParameter.SEARCH_TYPE, type.value) .put(InternalParameter.SEARCH_QUERY, query) @@ -476,7 +490,13 @@ open class SDK { * @param value Event value */ @JvmOverloads - fun track(event: String, category: String? = null, label: String? = null, value: Int? = null, listener: OnApiCallbackListener? = null) { + fun track( + event: String, + category: String? = null, + label: String? = null, + value: Int? = null, + listener: OnApiCallbackListener? = null + ) { val params = Params() params.put(InternalParameter.EVENT, event) if (category != null) { @@ -509,7 +529,13 @@ open class SDK { * @param email Email, если есть * @param phone Телефон, если есть */ - fun subscribeForPriceDrop(id: String, currentPrice: Double, email: String? = null, phone: String? = null, listener: OnApiCallbackListener? = null) { + fun subscribeForPriceDrop( + id: String, + currentPrice: Double, + email: String? = null, + phone: String? = null, + listener: OnApiCallbackListener? = null + ) { val params = Params() params.put(Params.Parameter.ITEM, id) params.put(Params.Parameter.PRICE, currentPrice.toString()) @@ -530,7 +556,12 @@ open class SDK { * @param email Email, если есть * @param phone Телефон, если есть */ - fun unsubscribeForPriceDrop(itemIds: Array, email: String? = null, phone: String? = null, listener: OnApiCallbackListener? = null) { + fun unsubscribeForPriceDrop( + itemIds: Array, + email: String? = null, + phone: String? = null, + listener: OnApiCallbackListener? = null + ) { val params = JSONObject() try { params.put("item_ids", java.lang.String.join(", ", *itemIds)) @@ -554,7 +585,13 @@ open class SDK { * @param email Email, если есть * @param phone Телефон, если есть */ - fun subscribeForBackInStock(id: String, email: String? = null, phone: String? = null, properties: JSONObject? = null, listener: OnApiCallbackListener? = null) { + fun subscribeForBackInStock( + id: String, + email: String? = null, + phone: String? = null, + properties: JSONObject? = null, + listener: OnApiCallbackListener? = null + ) { val params = Params() params.put(Params.Parameter.ITEM, id) if (properties != null) { @@ -578,7 +615,12 @@ open class SDK { * @param phone Телефон, если есть */ @JvmOverloads - fun unsubscribeForBackInStock(itemIds: Array, email: String? = null, phone: String? = null, listener: OnApiCallbackListener? = null) { + fun unsubscribeForBackInStock( + itemIds: Array, + email: String? = null, + phone: String? = null, + listener: OnApiCallbackListener? = null + ) { val params = JSONObject() try { params.put("item_ids", java.lang.String.join(", ", *itemIds)) @@ -611,8 +653,21 @@ open class SDK { * @param phone * @param subscriptions */ - fun manageSubscription(email: String?, phone: String?, subscriptions: HashMap, listener: OnApiCallbackListener? = null) { - manageSubscription(email, phone, null, null, null, subscriptions, listener) + fun manageSubscription( + email: String?, + phone: String?, + subscriptions: HashMap, + listener: OnApiCallbackListener? = null + ) { + manageSubscription( + email = email, + phone = phone, + externalId = null, + loyaltyId = null, + telegramId = null, + subscriptions = subscriptions, + listener = listener + ) } /** @@ -639,8 +694,15 @@ open class SDK { * @param subscriptions */ @JvmOverloads - fun manageSubscription(email: String?, phone: String?, externalId: String?, loyaltyId: String?, telegramId: String?, - subscriptions: HashMap, listener: OnApiCallbackListener? = null) { + fun manageSubscription( + email: String?, + phone: String?, + externalId: String?, + loyaltyId: String?, + telegramId: String?, + subscriptions: HashMap, + listener: OnApiCallbackListener? = null + ) { try { val params = JSONObject() for ((key, value) in subscriptions) { @@ -670,13 +732,7 @@ open class SDK { /** * Возвращает текущий сегмент для А/В тестирования */ - fun getSegment(): String { - if (instance == null) { - throw RuntimeException("You need initialize SDK before request segment") - } else { - return instance!!.segment - } - } + fun getSegment(): String = instance.segment /** * Add user to a segment @@ -686,7 +742,12 @@ open class SDK { * @param email * @param phone */ - fun addToSegment(segment_id: String, email: String?, phone: String?, listener: OnApiCallbackListener? = null) { + fun addToSegment( + segment_id: String, + email: String?, + phone: String?, + listener: OnApiCallbackListener? = null + ) { segmentMethod("add", segment_id, email, phone, listener) } @@ -698,7 +759,12 @@ open class SDK { * @param email * @param phone */ - fun removeFromSegment(segment_id: String, email: String?, phone: String?, listener: OnApiCallbackListener? = null) { + fun removeFromSegment( + segment_id: String, + email: String?, + phone: String?, + listener: OnApiCallbackListener? = null + ) { segmentMethod("remove", segment_id, email, phone, listener) } @@ -712,7 +778,13 @@ open class SDK { getAsync("segments/get", JSONObject(), listener) } - private fun segmentMethod(method: String, segmentId: String?, email: String?, phone: String?, listener: OnApiCallbackListener?) { + private fun segmentMethod( + method: String, + segmentId: String?, + email: String?, + phone: String?, + listener: OnApiCallbackListener? + ) { try { val params = JSONObject() if (segmentId != null) { @@ -800,9 +872,9 @@ open class SDK { } companion object { - lateinit var TAG: String - var NOTIFICATION_TYPE: String = "NOTIFICATION_TYPE" - var NOTIFICATION_ID: String = "NOTIFICATION_ID" + const val TAG = "SDK" + private const val NOTIFICATION_TYPE = "NOTIFICATION_TYPE" + private const val NOTIFICATION_ID = "NOTIFICATION_ID" private const val SID_FIELD = "sid" private const val SID_LAST_ACT_FIELD = "sid_last_act" private const val DID_FIELD = "did" @@ -814,19 +886,8 @@ open class SDK { private const val IMAGE_FIELD = "image" private const val IMAGES_FIELD = "images" - @SuppressLint("StaticFieldLeak") - @Volatile - private var instance: SDK? = null - - fun getInstance(): SDK { - if (instance == null) { - synchronized(this) { - if (instance == null) { - instance = SDK() - } - } - } - return instance!! + val instance: SDK by lazy { + SDK() } fun userAgent(): String { @@ -865,21 +926,30 @@ open class SDK { * @param remoteMessage */ fun onMessage(remoteMessage: RemoteMessage) { - instance?.notificationReceived(remoteMessage.data) - - instance?.onMessageListener?.let { listener -> - val data: MutableMap = HashMap(remoteMessage.data) - - remoteMessage.notification?.let { notification -> - notification.title?.takeIf { it.isNotEmpty() }?.let { data[TITLE_FIELD] = it } - notification.body?.takeIf { it.isNotEmpty() }?.let { data[BODY_FIELD] = it } - notification.imageUrl?.let { data[IMAGE_FIELD] = it.toString() } - } - - data[IMAGES_FIELD]?.takeIf { it.isNotEmpty() }?.let { data[IMAGES_FIELD] = it } + instance.notificationReceived(remoteMessage.data) + instance.onMessageListener?.let { listener -> + val data = prepareData(remoteMessage) listener.onMessage(data) } } + + private fun prepareData(remoteMessage: RemoteMessage): MutableMap { + val data: MutableMap = HashMap(remoteMessage.data) + remoteMessage.notification?.let { notification -> + addNotificationData(notification, data) + } + data[IMAGES_FIELD]?.takeIf { it.isNotEmpty() }?.let { data[IMAGES_FIELD] = it } + return data + } + + private fun addNotificationData( + notification: RemoteMessage.Notification, + data: MutableMap + ) { + notification.title?.takeIf { it.isNotEmpty() }?.let { data[TITLE_FIELD] = it } + notification.body?.takeIf { it.isNotEmpty() }?.let { data[BODY_FIELD] = it } + notification.imageUrl?.let { data[IMAGE_FIELD] = it.toString() } + } } } diff --git a/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/viewAdapters/ProductsAdapter.kt b/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/viewAdapters/ProductsAdapter.kt index 74db01dd..f6797e63 100644 --- a/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/viewAdapters/ProductsAdapter.kt +++ b/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/viewAdapters/ProductsAdapter.kt @@ -35,7 +35,9 @@ class ProductsAdapter(private val storiesView: StoriesView) : } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.product, parent, false)) + return ViewHolder( + LayoutInflater.from(parent.context).inflate(R.layout.product, parent, false) + ) } override fun onBindViewHolder(holder: ViewHolder, position: Int) { @@ -79,11 +81,14 @@ class ProductsAdapter(private val storiesView: StoriesView) : Log.d(SDK.TAG, "click: " + product.name + ", " + product.url) try { if (storiesView.clickListener?.onClick(product) == true) { - itemView.context.startActivity(Intent( + itemView.context.startActivity( + Intent( Intent.ACTION_VIEW, - Uri.parse(if (Strings.isNullOrEmpty(product.deeplink)) product.url else product.deeplink))) + Uri.parse(if (Strings.isNullOrEmpty(product.deeplink)) product.url else product.deeplink) + ) + ) } - SDK.getInstance().trackStory("click", storiesView.code, storyId, slideId) + SDK.instance.trackStory("click", storiesView.code, storyId, slideId) } catch (e: ActivityNotFoundException) { Log.e(SDK.TAG, e.message, e) Toast.makeText(itemView.context, "Unknown error", Toast.LENGTH_SHORT).show() diff --git a/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/StoriesView.kt b/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/StoriesView.kt index 0eb9c5b6..6aed17f7 100644 --- a/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/StoriesView.kt +++ b/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/StoriesView.kt @@ -29,9 +29,9 @@ class StoriesView : ConstraintLayout, ClickListener { private var adapter: StoriesAdapter? = null private val list: MutableList = ArrayList() private var observer: ContentObserver? = null - val settings: Settings = Settings() - var code: String? = null - var player: Player? = null + val settings: Settings = Settings() + var code: String? = null + var player: Player? = null var clickListener: OnLinkClickListener? = null var isMute: Boolean = true private set @@ -46,7 +46,11 @@ class StoriesView : ConstraintLayout, ClickListener { parseAttrs(attrs) } - constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context!!, attrs, defStyleAttr) { + constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super( + context!!, + attrs, + defStyleAttr + ) { parseAttrs(attrs) } @@ -101,7 +105,7 @@ class StoriesView : ConstraintLayout, ClickListener { //Запрашиваем сторисы this.code?.let { - SDK.getInstance().stories(it, object : OnApiCallbackListener() { + SDK.instance.stories(it, object : OnApiCallbackListener() { override fun onSuccess(response: JSONObject?) { response?.let { response -> Log.d("stories", response.toString()) diff --git a/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/StoryDialog.kt b/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/StoryDialog.kt index 08ee7e8d..70be5efe 100644 --- a/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/StoryDialog.kt +++ b/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/StoryDialog.kt @@ -18,8 +18,16 @@ import com.personalizatio.R import com.personalizatio.stories.models.Story import kotlin.math.abs -class StoryDialog(storiesView: StoriesView, stories: List, startPosition: Int, completeListener: Runnable) - : Dialog(storiesView.context, android.R.style.Theme_Translucent_NoTitleBar), PullDismissLayout.Listener { +class StoryDialog( + storiesView: StoriesView, + stories: List, + startPosition: Int, + completeListener: Runnable +) : Dialog( + storiesView.context, + android.R.style.Theme_Translucent_NoTitleBar +), PullDismissLayout.Listener { + private val stories: List private val storyViews = HashMap() private val adapter: ViewPagerAdapter @@ -79,7 +87,8 @@ class StoryDialog(storiesView: StoriesView, stories: List, startPosition: if (context.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { val dm = context.resources.displayMetrics val nextItemVisiblePx = (dm.widthPixels - dm.heightPixels * 9f / 16) / 2f - val currentItemHorizontalMarginPx = nextItemVisiblePx + context.resources.getDimension(R.dimen.viewpager_current_item_horizontal_margin) + val currentItemHorizontalMarginPx = + nextItemVisiblePx + context.resources.getDimension(R.dimen.viewpager_current_item_horizontal_margin) val pageTranslationX = nextItemVisiblePx + currentItemHorizontalMarginPx mViewPager.setPageTransformer { page: View, position: Float -> val absPosition = abs(position.toDouble()) @@ -90,7 +99,12 @@ class StoryDialog(storiesView: StoriesView, stories: List, startPosition: page.alpha = (1 - (0.7f * absPosition)).toFloat() } mViewPager.addItemDecoration(object : ItemDecoration() { - override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) { + override fun getItemOffsets( + outRect: Rect, + view: View, + parent: RecyclerView, + state: RecyclerView.State + ) { super.getItemOffsets(outRect, view, parent, state) val margin = currentItemHorizontalMarginPx.toInt() outRect.right = margin @@ -111,7 +125,7 @@ class StoryDialog(storiesView: StoriesView, stories: List, startPosition: getHolder(i)?.stopStories() } } - getHolder(position)?.startStories() + getHolder(position)?.startStories() } override fun onPageScrollStateChanged(state: Int) { @@ -152,7 +166,8 @@ class StoryDialog(storiesView: StoriesView, stories: List, startPosition: internal class PagerHolder(itemView: StoryView) : RecyclerView.ViewHolder(itemView) - internal inner class ViewPagerAdapter(private val stateListener: OnProgressState) : RecyclerView.Adapter() { + internal inner class ViewPagerAdapter(private val stateListener: OnProgressState) : + RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PagerHolder { return PagerHolder(StoryView(storiesView, stateListener)) } diff --git a/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/StoryView.kt b/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/StoryView.kt index 92ff4706..7dd99698 100644 --- a/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/StoryView.kt +++ b/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/StoryView.kt @@ -29,7 +29,8 @@ import com.personalizatio.stories.views.storyItem.StoryItemView.OnPageListener @SuppressLint("ViewConstructor") internal class StoryView @SuppressLint("ClickableViewAccessibility") constructor( private val storiesView: StoriesView, //Heading - private val stateListener: OnProgressState) : ConstraintLayout(storiesView.context), StoriesListener, Player.Listener { + private val stateListener: OnProgressState +) : ConstraintLayout(storiesView.context), StoriesListener, Player.Listener { private var story: Story? = null private var pressTime = 0L @@ -110,7 +111,12 @@ internal class StoryView @SuppressLint("ClickableViewAccessibility") constructor } if (storiesStarted) { story?.let { story -> - SDK.getInstance().trackStory("view", storiesView.code, story.id, story.getSlide(position).id) + SDK.instance.trackStory( + event = "view", + code = storiesView.code, + storyId = story.id, + slideId = story.getSlide(position).id + ) playVideo() } } @@ -193,8 +199,7 @@ internal class StoryView @SuppressLint("ClickableViewAccessibility") constructor override fun onTracksChanged(tracks: Tracks) { val player = com.personalizatio.stories.Player.player var contentDuration = 0L - if(player != null) - { + if (player != null) { contentDuration = player.contentDuration } @@ -280,7 +285,7 @@ internal class StoryView @SuppressLint("ClickableViewAccessibility") constructor holders[position] = this mute.visibility = GONE slide?.let { storyItem.update(slide, position, storiesView.code!!, story!!.id) } - onTouchListener?.let { listener -> storyItem.setOnTouchListener(listener) } + onTouchListener?.let { listener -> storyItem.setOnTouchListener(listener) } //Устанавливаем загрузку видео, если биндим текущий элемент if (position == mViewPager.currentItem) { @@ -418,7 +423,12 @@ internal class StoryView @SuppressLint("ClickableViewAccessibility") constructor if (!storiesStarted) { storiesStarted = true playVideo() - SDK.getInstance().trackStory("view", storiesView.code, story.id, story.getSlide(startPosition).id) + SDK.instance.trackStory( + event = "view", + code = storiesView.code, + storyId = story.id, + slideId = story.getSlide(startPosition).id + ) } if (!locked) { diff --git a/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/storyItem/StoryItemView.kt b/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/storyItem/StoryItemView.kt index 1eaf7811..a5ad64ce 100644 --- a/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/storyItem/StoryItemView.kt +++ b/personalizatio-sdk/src/main/kotlin/com/personalizatio/stories/views/storyItem/StoryItemView.kt @@ -296,7 +296,12 @@ class StoryItemView(private val storiesView: StoriesView) : ConstraintLayout(sto || product != null && clickListener.onClick(product)) { context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(link))) } - SDK.getInstance().trackStory("click", code, storyId, slide.id) + SDK.instance.trackStory( + event = "click", + code = code, + storyId = storyId, + slideId = slide.id + ) } catch (e: ActivityNotFoundException) { Log.e(SDK.TAG, e.message, e) Toast.makeText(context, "Unknown error", Toast.LENGTH_SHORT).show() @@ -391,7 +396,12 @@ class StoryItemView(private val storiesView: StoriesView) : ConstraintLayout(sto header.setOnTouchListener { _: View?, event: MotionEvent -> if (event.action == MotionEvent.ACTION_UP) { context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(element.link))) - SDK.getInstance().trackStory("click", code, storyId, slideId) + SDK.instance.trackStory( + event = "click", + code = code, + storyId = storyId, + slideId = slideId + ) } true } diff --git a/personalizatio-sdk/src/rees46/kotlin/com/rees46/sdk/REES46.kt b/personalizatio-sdk/src/rees46/kotlin/com/rees46/sdk/REES46.kt index ac6f5064..8e48ed81 100644 --- a/personalizatio-sdk/src/rees46/kotlin/com/rees46/sdk/REES46.kt +++ b/personalizatio-sdk/src/rees46/kotlin/com/rees46/sdk/REES46.kt @@ -11,17 +11,14 @@ import kotlinx.coroutines.* class REES46 private constructor() : SDK() { companion object { - const val TAG: String = "REES46" - protected const val PREFERENCES_KEY: String = "rees46.sdk" - protected val API_URL: String = when { + private const val PREFERENCES_KEY: String = "rees46.sdk" + private val API_URL: String = when { BuildConfig.DEBUG -> "http://dev.api.rees46.com:8000/" else -> "https://api.rees46.ru/" } - fun getInstance() : SDK { - return SDK.getInstance() - } + fun getInstance() : SDK = instance /** * Initialize api @@ -33,9 +30,15 @@ class REES46 private constructor() : SDK() { val apiUrl = apiHost?.let { "https://$it/" } ?: API_URL val sdk = getInstance() - sdk.initialize(context, shopId, apiUrl, TAG, PREFERENCES_KEY, "android") - - // Дефолтное отображение сообщения без кастомизации + sdk.initialize( + context = context, + shopId = shopId, + apiUrl = apiUrl, + preferencesKey = PREFERENCES_KEY, + stream = "android" + ) + + // Default message equipment without customization getInstance().setOnMessageListener { data: Map -> GlobalScope.launch(Dispatchers.Main) { val images = withContext(Dispatchers.IO) {