This repository was archived by the owner on Oct 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
This repository was archived by the owner on Oct 20, 2025. It is now read-only.
π‘ Suggestion: Avoid third-party model dependency Β #38
Copy link
Copy link
Open
Description
ποΈ Context
I think an SDK must reduce the dependencies with another dependencies. It is a good idea to avoid usage of RemoteMessage in braze functions inside BrazeFirebaseMessagingService. I mean is better to just pass what you are going to use.
π My problem
In my case, I'm using this library as a component that belong to my background message layer. My problem is the way that you use a firebase model force me to include firebase in my Braze component.
π§° Example of potencial improvements:
Function: isBrazePushNotification
fun isBrazePushNotification(remoteMessage: RemoteMessage): Boolean {
val remoteMessageData = remoteMessage.data
return "true" == remoteMessageData[Constants.BRAZE_PUSH_BRAZE_KEY]
}π‘ Suggestion:
fun isBrazePushNotification(data: Map<String, String>): Boolean {
return "true" == data[Constants.BRAZE_PUSH_BRAZE_KEY]
}Function: handleBrazeRemoteMessage
fun handleBrazeRemoteMessage(context: Context, remoteMessage: RemoteMessage): Boolean {
if (!isBrazePushNotification(remoteMessage)) {
brazelog(I) { "Remote message did not originate from Braze. Not consuming remote message: $remoteMessage" }
return false
}
val remoteMessageData = remoteMessage.data
brazelog(I) { "Got remote message from FCM: $remoteMessageData" }
val pushIntent = Intent(BrazePushReceiver.FIREBASE_MESSAGING_SERVICE_ROUTING_ACTION)
val bundle = Bundle()
for ((key, value) in remoteMessageData) {
brazelog(V) { "Adding bundle item from FCM remote data with key: $key and value: $value" }
bundle.putString(key, value)
}
pushIntent.putExtras(bundle)
BrazePushReceiver.handleReceivedIntent(context, pushIntent)
return true
}π‘ Suggestion:
fun handleBrazeRemoteMessage(context: Context, data: Map<String, String>): Boolean {
if (!isBrazePushNotification(data)) {
brazelog(I) { "Remote message did not originate from Braze. Not consuming remote message: $remoteMessage" }
return false
}
brazelog(I) { "Got remote message from FCM: $data" }
val pushIntent = Intent(BrazePushReceiver.FIREBASE_MESSAGING_SERVICE_ROUTING_ACTION)
val bundle = Bundle()
for ((key, value) in data) {
brazelog(V) { "Adding bundle item from FCM remote data with key: $key and value: $value" }
bundle.putString(key, value)
}
pushIntent.putExtras(bundle)
BrazePushReceiver.handleReceivedIntent(context, pushIntent)
return true
}Metadata
Metadata
Assignees
Labels
No labels