File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
core/notification/src/main/java/team/aliens/dms/android/core/notification Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ import com.google.firebase.messaging.FirebaseMessaging
44import kotlinx.coroutines.CoroutineScope
55import kotlinx.coroutines.Dispatchers
66import kotlinx.coroutines.launch
7+ import kotlinx.coroutines.tasks.await
8+ import kotlinx.coroutines.withContext
79import team.aliens.dms.android.data.notification.repository.NotificationRepository
810import 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}
You canโt perform that action at this time.
0 commit comments