Skip to content

Comments

Removed Public Dependency on Firebase Messaging#28

Open
mikemilla wants to merge 15 commits intomasterfrom
feature/no-pub-fcm-dep
Open

Removed Public Dependency on Firebase Messaging#28
mikemilla wants to merge 15 commits intomasterfrom
feature/no-pub-fcm-dep

Conversation

@mikemilla
Copy link
Collaborator

Now, the firebase dependency does not get exposed publicly. This will allow developers to use different versions of firebase messaging in their projects than what we have in the package.

This change makes things a bit more flexible than what we currently offer, but does add a couple more steps to get up and running with Courier.

open fun onPushNotificationClicked(pushNotification: Map<String, String>) {}

open fun onPushNotificationDelivered(message: RemoteMessage) {}
open fun onPushNotificationDelivered(pushNotification: Map<String, String>) {}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can no longer expose the public class at this point. Using a simple map is more ideal.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking: since we're now taking an implementation dependency on Firebase Messaging, we could reference RemoteMessage in the Courier SDK, however we avoid referencing Firebase classes in Courier's public API since they're not exposed through the Courier SDK

import com.google.firebase.messaging.RemoteMessage

fun RemoteMessage.presentNotification(context: Context, handlingClass: Class<*>?, icon: Int = android.R.drawable.ic_dialog_info, settingsTitle: String = "Notification settings") {
fun CourierPushNotificationIntent.presentNotification(title: String?, body: String?, icon: Int = android.R.drawable.ic_dialog_info, settingsTitle: String = "Notification settings") {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this extension to the intent class

}
}

val RemoteMessage.pushNotification: Map<String, Any?>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropping this for now. This extension is used by react native and flutter. We will likely need to massage things a bit more when we get there.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean those SDKs will need updates, too?

}

// Returns the last message that was delivered via the event bus
fun onPushNotificationEvent(onEvent: (event: CourierPushNotificationEvent) -> Unit) = coroutineScope.launch(Dispatchers.Main) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to change this to use a listener of some sort in the future. Not a huge deal for now

Copy link

@danasilver danasilver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking: this should be a major version bump of the SDK since it's a breaking change, and we ought to document which versions of the Firebase BOM/Firebase Messaging SDK are supported


// Firebase
implementation platform('com.google.firebase:firebase-bom:XXXX')
implementation "com.google.firebase:firebase-messaging"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: These could use consistent syntax:

implementation platform("com.google.firebase:firebase-bom:X.Y.Z")
implementation("com.google.firebase:firebase-messaging")

The Android docs use double quotes here, too, if we want to stay consistent with those examples: https://developer.android.com/develop/ui/compose/bom#kts

open fun onPushNotificationClicked(pushNotification: Map<String, String>) {}

open fun onPushNotificationDelivered(message: RemoteMessage) {}
open fun onPushNotificationDelivered(pushNotification: Map<String, String>) {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking: since we're now taking an implementation dependency on Firebase Messaging, we could reference RemoteMessage in the Courier SDK, however we avoid referencing Firebase classes in Courier's public API since they're not exposed through the Courier SDK

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come this is removed?

}
}

val RemoteMessage.pushNotification: Map<String, Any?>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean those SDKs will need updates, too?

data class CourierPushNotificationEvent(
val trackingEvent: CourierTrackingEvent,
val remoteMessage: RemoteMessage
val data: Map<String, String>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd consider creating a class for the message data (ex. CourierMessage or something) that's more descriptive to pass around than a plain Map and let's us extend functionality down the line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants