@@ -2,8 +2,11 @@ package cloud.mindbox.mobile_sdk
22
33import android.content.Context
44import com.orhanobut.hawk.Hawk
5- import kotlinx.coroutines.*
5+ import kotlinx.coroutines.CoroutineScope
66import kotlinx.coroutines.Dispatchers.Default
7+ import kotlinx.coroutines.Job
8+ import kotlinx.coroutines.async
9+ import kotlinx.coroutines.launch
710
811object Mindbox {
912
@@ -16,7 +19,12 @@ object Mindbox {
1619
1720 Hawk .init (context).build()
1821 mindboxScope.launch {
19- initializeSdk(context, callback)
22+ if (MindboxPreferences .isFirstInitialize) {
23+ firstInitialize(context, callback)
24+ MindboxPreferences .isFirstInitialize = false
25+ } else {
26+ secondaryInitialize()
27+ }
2028 }
2129 }
2230
@@ -28,14 +36,22 @@ object Mindbox {
2836 return MindboxPreferences .firebaseToken
2937 }
3038
31- private suspend fun initializeSdk (context : Context , callback : (String? , String? ) -> Unit ) {
39+ private suspend fun firstInitialize (context : Context , callback : (String? , String? ) -> Unit ) {
3240 val firebaseToken = mindboxScope.async { IdentifierManager .getFirebaseToken() }
3341 val adid = mindboxScope.async { IdentifierManager .getAdsIdentification(context) }
3442
3543 registerClient(firebaseToken.await(), adid.await(), callback)
3644 }
3745
38- private fun registerClient (firebaseToken : String? , deviceUuid : String? , callback : (String? , String? ) -> Unit ) {
46+ private suspend fun secondaryInitialize () {
47+
48+ }
49+
50+ private fun registerClient (
51+ firebaseToken : String? ,
52+ deviceUuid : String? ,
53+ callback : (String? , String? ) -> Unit
54+ ) {
3955 callback.invoke(firebaseToken, deviceUuid)
4056 }
4157
0 commit comments