Customize Android push notification title
When you send a push notification to Android devices, Android automatically uses your app's name as the title of push notifications.
If you'd rather use a different title, there are two ways you can customize push titles:
1. Add a data field called "title"
To edit the title of a single push, click Advanced Options. Under Data, add a text field called "title." Type your push title into the field on the right ("Title Android").
A best practice is to keep push titles brief (5 words or fewer). Or, you can choose to have no title at all by leaving the title field empty.
Send yourself a preview
The on-screen preview device will not display your custom title — data fields aren't evaluated until the message sends. To see how your push title will look, preview the message on your test device.
Note that you're only customizing the title for this push notification. To apply a consistent change (so you don't have to perform this step every time you create a push notification), use the customizer method below.
2. Implement the push customizer
You may have implemented the LeanplumPushService.setCustomizer
during your Leanplum SDK setup.
Once the customizer is implemented you can customize a push notification title at the app level, meaning the title will automatically display in all future pushes sent from this app.
LeanplumPushService.setCustomizer(new LeanplumPushNotificationCustomizer() {
@Override
public void customize(NotificationCompat.Builder builder, Bundle bundle) {
builder.setContentTitle("SAMPLE TITLE");
}
@Override
public void customize(Notification.Builder builder, Bundle bundle, @Nullable Notification.Style style) {
// leave blank
}
});
For help with the customizer, see our push notification customizer guide.
Updated about 3 years ago