Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.plottwist.core.push

import android.app.PendingIntent
import android.content.Intent
import com.google.firebase.messaging.Constants
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import com.plottwist.core.notification.TukNotificationManager
Expand All @@ -15,20 +16,16 @@ class TukFirebaseMessagingService : FirebaseMessagingService() {
@Inject
lateinit var tukNotificationManager: TukNotificationManager


override fun onNewToken(token: String) {
super.onNewToken(token)
}

override fun onMessageReceived(message: RemoteMessage) {
super.onMessageReceived(message)

message.notification?.let { notificationMessage ->
val title = notificationMessage.title ?: TukNotificationManager.DEFAULT_TITLE
val description = notificationMessage.body ?: TukNotificationManager.DEFAULT_DESCRIPTION
val deeplink = message.data.get("deepLink") ?: ""
sendNotification(title, description, deeplink)
}
val title = message.data.get("title") ?: ""
val description = message.data.get("body") ?: ""
val deeplink = message.data.get("deepLink") ?: ""
sendNotification(title, description, deeplink)
}

private fun sendNotification(title: String, description: String, deeplink: String) {
Expand All @@ -52,4 +49,17 @@ class TukFirebaseMessagingService : FirebaseMessagingService() {
)
)
}


override fun handleIntent(intent: Intent?) {
val newIntent = intent?.apply {
val newExtras = extras?.apply {
remove(Constants.MessageNotificationKeys.ENABLE_NOTIFICATION)
remove("gcm.notification.e")
}
replaceExtras(newExtras)
}
super.handleIntent(newIntent)

}
}