@@ -27,16 +27,18 @@ class NavigationHelper @Inject constructor() {
2727 fun handleFCMNavigate (
2828 isColdStart : Boolean ,
2929 extras : Bundle ? ,
30- onInit : () -> Unit
30+ onInit : () -> Unit ,
31+ readNotification : (String ) -> Unit ,
3132 ) {
33+ val notificationId = extras?.getString(NotificationKeys .NOTIFICATION_ID ) ? : run {
34+ if (isColdStart) onInit()
35+ return
36+ }
37+
38+ readNotification(notificationId)
39+
3240 val notificationType = NotificationType .create(
33- extras?.getString(NotificationKeys .NOTIFICATION_TYPE ) ? : run {
34- if (isColdStart) {
35- onInit()
36- return
37- }
38- return
39- }
41+ extras.getString(NotificationKeys .NOTIFICATION_TYPE ) ? : return
4042 )
4143
4244 when (notificationType) {
@@ -92,36 +94,27 @@ class NavigationHelper @Inject constructor() {
9294 fun handleNotificationNavigate (notification : Notification ) {
9395 val destinations = when (notification.notificationType) {
9496 APPLICANT -> {
95- val notificationContent =
96- notification.notificationDetails as ? NotificationContent .ApplicantNotification
97-
98- notificationContent?.let { content ->
99- listOf (
100- NavigationEvent .NavigateTo (CenterJobDetail (content.jobPostingId)),
101- )
97+ (notification.notificationDetails as ? NotificationContent .ApplicantNotification )?.let { content ->
98+ listOf (NavigationEvent .NavigateTo (CenterJobDetail (content.jobPostingId)))
10299 } ? : listOf ()
103100 }
104101
105102 NEW_JOB_POSTING -> {
106- val notificationContent =
107- notification.notificationDetails as ? NotificationContent .NewJobPostingNotification
108-
109- notificationContent?.let { content ->
103+ (notification.notificationDetails as ? NotificationContent .NewJobPostingNotification )?.let { content ->
110104 listOf (
111105 NavigationEvent .NavigateTo (
112106 WorkerJobDetail (
113- jobPostingId = content.jobPostingId,
114- jobPostingType = JobPostingType .CAREMEET .name,
107+ content.jobPostingId,
108+ JobPostingType .CAREMEET .name
115109 )
116- ),
110+ )
117111 )
118112 } ? : listOf ()
119113 }
120114
121115 else -> listOf ()
122116 }
123-
124- destinations.onEach { destination -> _navigationFlow .trySend(destination) }
117+ destinations.forEach { _navigationFlow .trySend(it) }
125118 }
126119}
127120
@@ -148,6 +141,7 @@ enum class NotificationType {
148141}
149142
150143private object NotificationKeys {
144+ const val NOTIFICATION_ID = " notificationId"
151145 const val NOTIFICATION_TYPE = " notificationType"
152146 const val JOB_POSTING_ID = " jobPostingId"
153147}
0 commit comments