diff --git a/src/main/kotlin/com/psr/psr/notification/service/NotificationService.kt b/src/main/kotlin/com/psr/psr/notification/service/NotificationService.kt index 8bcb405..2c8d291 100644 --- a/src/main/kotlin/com/psr/psr/notification/service/NotificationService.kt +++ b/src/main/kotlin/com/psr/psr/notification/service/NotificationService.kt @@ -44,7 +44,7 @@ class NotificationService( NotificationType.NEW_ORDER )) - if (orderReceiver.deviceToken != null) { + if (isPushNotiAvailable(orderReceiver)) { val message: FcmMessage = notiAssembler.makeMessage( orderReceiver.deviceToken!!, productName, @@ -67,7 +67,7 @@ class NotificationService( NotificationType.CHANGED_ORDER_STATUS )) - if (orderer.deviceToken != null) { + if (isPushNotiAvailable(orderer)) { val message: FcmMessage = notiAssembler.makeMessage( orderer.deviceToken!!, productName, @@ -90,7 +90,7 @@ class NotificationService( NotificationType.TWO_MONTH_ORDER )) - if (orderer.deviceToken != null) { + if (isPushNotiAvailable(orderer)) { val message: FcmMessage = notiAssembler.makeMessage( orderer.deviceToken!!, productName, @@ -102,6 +102,11 @@ class NotificationService( } } + // 알림 수신 상태 체크 + fun isPushNotiAvailable(user: User): Boolean { + return user.deviceToken != null && user.notification + } + // firebase accessToken 발급 private fun getAccessToken(): String? { val firebaseConfigPath = "firebase-service-key.json"