Skip to content

Commit cb9f023

Browse files
authored
๐Ÿ”€ :: (#770) device token ์กฐํšŒ ๋น„๋™๊ธฐ ์ˆœ์ฐจ์  ์ฒ˜๋ฆฌ
๐Ÿ”€ :: (#770) device token ์กฐํšŒ ๋น„๋™๊ธฐ ์ˆœ์ฐจ์  ์ฒ˜๋ฆฌ
2 parents e52f425 + dab2bfa commit cb9f023

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

โ€Žcore/notification/src/main/java/team/aliens/dms/android/core/notification/DeviceTokenManager.ktโ€Ž

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import com.google.firebase.messaging.FirebaseMessaging
44
import kotlinx.coroutines.CoroutineScope
55
import kotlinx.coroutines.Dispatchers
66
import kotlinx.coroutines.launch
7+
import kotlinx.coroutines.tasks.await
8+
import kotlinx.coroutines.withContext
79
import team.aliens.dms.android.data.notification.repository.NotificationRepository
810
import javax.inject.Inject
911

@@ -15,13 +17,9 @@ class DeviceTokenManager @Inject constructor(
1517
}
1618

1719
suspend fun fetchDeviceToken() {
18-
FirebaseMessaging.getInstance().token.addOnCompleteListener { task ->
19-
if (!task.isSuccessful) {
20-
// TODO: Handle error
21-
}
22-
CoroutineScope(Dispatchers.IO).launch {
23-
notificationRepository.saveDeviceToken(deviceToken = task.result)
24-
}
20+
val token = FirebaseMessaging.getInstance().token.await()
21+
withContext(Dispatchers.IO) {
22+
notificationRepository.saveDeviceToken(deviceToken = token)
2523
}
2624
}
2725
}

0 commit comments

Comments
ย (0)