Skip to content

Commit

Permalink
[CHORE]#217 : FCM 토큰 로드 시에, initRefresh 하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongjaino committed Jan 21, 2025
1 parent e225abf commit 43b32b6
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ interface MessagingDataSource {
suspend fun getFcmToken(): String

suspend fun removeFcmToken()

suspend fun initMessaging()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,18 @@ package com.bff.wespot.data.remote.source.firebase.messaging

import com.bff.wespot.data.remote.extensions.await
import com.google.firebase.messaging.FirebaseMessaging
import kotlinx.coroutines.suspendCancellableCoroutine
import timber.log.Timber
import javax.inject.Inject

class MessagingDataSourceImpl @Inject constructor(
private val messaging: FirebaseMessaging,
) : MessagingDataSource {
override suspend fun getFcmToken(): String {
return suspendCancellableCoroutine { continuation ->
messaging.token.addOnCompleteListener {
continuation.resumeWith(Result.success(it.result))
}.addOnFailureListener {
Timber.e("Update FcmToken Failed Exception : ", it)
}
}
messaging.isAutoInitEnabled = true
return messaging.token.await()
}

override suspend fun removeFcmToken() {
messaging.isAutoInitEnabled = false
messaging.deleteToken().await()
}

override suspend fun initMessaging() {
messaging.isAutoInitEnabled = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ class MessagingRepositoryImpl @Inject constructor(
override suspend fun getFcmToken(): String = messagingDataSource.getFcmToken()

override suspend fun removeFcmToken() = messagingDataSource.removeFcmToken()

override suspend fun initMessaging() = messagingDataSource.initMessaging()
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ interface MessagingRepository {
suspend fun getFcmToken(): String

suspend fun removeFcmToken()

suspend fun initMessaging()
}

0 comments on commit 43b32b6

Please sign in to comment.