Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.
This repository was archived by the owner on Oct 20, 2025. It is now read-only.

πŸ’‘ Suggestion: Avoid third-party model dependency Β #38

@gustavo-pedreros

Description

@gustavo-pedreros

πŸ—’οΈ 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions