Giter VIP home page Giter VIP logo

braze-segment-android's People

Contributors

bryanlogan avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

braze-segment-android's Issues

๐Ÿ’ก Suggestion: Avoid third-party model dependency

๐Ÿ—’๏ธ 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
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.