Push notifications
Get started setting up push notifications for Android. Our Android SDK supports push notifications over FCM.
This page is part of an introductory series to help you get started with the essential features of our SDK. The highlighted step(s) below are covered on this page. Before you continue, make sure you've implemented previous features—i.e. you can't identify people before you initialize the SDK!
Before you begin
This page explains how to receive push notifications using our SDK. However, before you can send push notifications to your audience, you need to enable Customer.io to send push notifications through Firebase Cloud Messaging (FCM).
This process lets you receive basic push notifications in your app—a title and a message body. To send a notification with an image, link, etc, complete the process on this page, and then see our rich push documentation.
Check out our sample app!
How it works
Before a device can receive a push notification, you must:
- Set up FCM.
- Implement the
messaging-push-fcm
SDK. - Identify a person. This associates a push token with the person, so that they can receive push notifications.
- Set up a campaign to send a push notification through the Customer.io composer.
Set up push
You must implement the Push Messaging SDK to use push notification features.
implementation 'io.customer.android:messaging-push-fcm:<version-here>'
The SDK adds a FirebaseMessagingService
to the app manifest automatically, so you don’t have to perform additional setup to handle incoming push messages.
If your application implements its own FirebaseMessagingService
, make sure that when you call onMessageReceived
and onNewToken
methods, you also call CustomerIOFirebaseMessagingService.onMessageReceived
and CustomerIOFirebaseMessagingService.onNewToken
respectively.
class FirebaseMessagingService : FirebaseMessagingService() {
override fun onMessageReceived(message: RemoteMessage) {
val handled = CustomerIOFirebaseMessagingService.onMessageReceived(message)
if (handled) {
logger.breadcrumb(this, "Push notification has been handled", null)
}
}
override fun onNewToken(token: String) {
CustomerIOFirebaseMessagingService.onNewToken(token)
}
Push notifications launched from the SDK are currently posted to our default channel—[your app name] Channel
. In the future, we plan to let you customize channels/categories so that users can subscribe and unsubscribe to content categories as necessary.
Capture push metrics
Customer.io supports three device-side metrics that help you determine the efficacy of your push notifications: delivered
, opened
, and converted
.
By default, the messaging-push-fcm
SDK automatically tracks opened
and delivered
for push notifications originating from Customer.io. Otherwise, you can track push metrics with the trackMetric
method.
CustomerIO.instance().trackMetric(
deliveryID = deliveryId,
deviceToken = deliveryToken,
event = MetricEvent.delivered
)