Add logs for invalid push data

This commit is contained in:
sim 2022-09-08 17:16:55 +02:00
parent 3e12907b26
commit a17a4fe4b1
2 changed files with 9 additions and 2 deletions

View File

@ -27,9 +27,12 @@ import im.vector.app.core.pushers.PushersManager
import im.vector.app.core.pushers.UnifiedPushHelper
import im.vector.app.core.pushers.VectorPushHandler
import im.vector.app.features.settings.VectorPreferences
import org.matrix.android.sdk.api.logger.LoggerTag
import timber.log.Timber
import javax.inject.Inject
private val loggerTag = LoggerTag("Push", LoggerTag.SYNC)
@AndroidEntryPoint
class VectorFirebaseMessagingService : FirebaseMessagingService() {
@Inject lateinit var fcmHelper: FcmHelper
@ -41,7 +44,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
@Inject lateinit var unifiedPushHelper: UnifiedPushHelper
override fun onNewToken(token: String) {
Timber.d("New Firebase token")
Timber.tag(loggerTag.value).d("New Firebase token")
fcmHelper.storeFcmToken(token)
if (
vectorPreferences.areNotificationEnabledForDevice() &&
@ -53,9 +56,11 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
}
override fun onMessageReceived(message: RemoteMessage) {
Timber.d("New Firebase message")
Timber.tag(loggerTag.value).d("New Firebase message")
pushParser.parsePushDataFcm(message.data)?.let {
vectorPushHandler.handle(it)
} ?: run {
Timber.tag(loggerTag.value).w("Invalid received data Json format")
}
}
}

View File

@ -61,6 +61,8 @@ class VectorUnifiedPushMessagingReceiver : MessagingReceiver() {
Timber.tag(loggerTag.value).d("New message")
pushParser.parsePushDataUnifiedPush(message)?.let {
vectorPushHandler.handle(it)
} ?: run {
Timber.tag(loggerTag.value).w("Invalid received data Json format")
}
}