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> val syncSendUpsertFlow: Flow<SyncSendUpsertData>
/** /**
* Handles the necessary steps to take when a push notification with a legacy FCM [data] * Handles the necessary steps to take when a push notification payload is received.
* payload is received.
*/
fun onMessageReceived(data: String)
/**
* Handles the necessary steps to take when a push notification with FCM v1 payload is
* received.
*/ */
fun onMessageReceived(data: Map<String, String>) fun onMessageReceived(data: Map<String, String>)

View file

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

View file

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

View file

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