Skip to content

Commit

Permalink
Remove legacy GCM notification support (#1464)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-livefront authored Jun 18, 2024
1 parent 3ea15e3 commit 37a53d4
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 797 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit 37a53d4

Please sign in to comment.