Remove legacy GCM notification support (#1464)

This commit is contained in:
David Perez 2024-06-18 14:30:24 -05:00 committed by Álison Fernandes
parent f4bdf5178a
commit 5e52b5a53d
5 changed files with 107 additions and 806 deletions

View file

@ -65,14 +65,7 @@ interface PushManager {
val syncSendUpsertFlow: Flow<SyncSendUpsertData>
/**
* Handles the necessary steps to take when a push notification with a legacy FCM [data]
* payload is received.
*/
fun onMessageReceived(data: String)
/**
* Handles the necessary steps to take when a push notification with FCM v1 payload is
* received.
* Handles the necessary steps to take when a push notification payload is received.
*/
fun onMessageReceived(data: Map<String, String>)

View file

@ -107,11 +107,6 @@ class PushManagerImpl @Inject constructor(
.launchIn(unconfinedScope)
}
override fun onMessageReceived(data: String) {
val notification = json.decodeFromStringOrNull<BitwardenNotification>(data) ?: return
onMessageReceived(notification)
}
override fun onMessageReceived(data: Map<String, String>) {
val notificationType = data["type"]
?.let { json.decodeFromStringOrNull<NotificationType>(string = it) }

View file

@ -1,8 +1,5 @@
package com.x8bit.bitwarden.data.platform.manager.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* Represents a Bitwarden push notification.
*
@ -11,9 +8,8 @@ import kotlinx.serialization.Serializable
* @property notificationType The type of notification.
* @property payload Data associated with the push notification.
*/
@Serializable
data class BitwardenNotification(
@SerialName("contextId") val contextId: String?,
@SerialName("type") val notificationType: NotificationType,
@SerialName("payload") val payload: String,
val contextId: String?,
val notificationType: NotificationType,
val payload: String,
)

View file

@ -17,10 +17,7 @@ class BitwardenFirebaseMessagingService : FirebaseMessagingService() {
lateinit var pushManager: PushManager
override fun onMessageReceived(message: RemoteMessage) {
message
.data["data"]
?.let { pushManager.onMessageReceived(it) }
?: pushManager.onMessageReceived(message.data)
pushManager.onMessageReceived(message.data)
}
override fun onNewToken(token: String) {