HTML push notifications
This reference article covers how to implement HTML push notifications in your Android application.
Platform availability
This feature is only available for Android—not FireOS.
How it works
In Braze SDK version 3.1.1, HTML can be sent to a device to render multiplier text in push notifications.
This example is rendered with the following HTML:
1
2
3
<p><span style="color: #99cc00;">M</span>u<span style="color: #008080;">lti</span>Colo<span style="color: #ff6600;">r</span> <span style="color: #000080;">P</span><span style="color: #00ccff;">u</span><span style="color: #ff0000;">s</span><span style="color: #808080;">h</span></p>
<p><em>test</em> <span style="text-decoration: underline; background-color: #ff6600;"><strong>message</strong></span></p>
Keep in mind that, Android limits which HTML elements and tags are valid in your push notifications. For example, marquee
is not allowed.
Multicolor text rendering is device-specific and may not display based on Android device or version.
Supported HTML tags
Currently, Google doesn’t list their supported HTML tags for Android directly in their documentation—this information can only be found in their Git repository’s Html.java
file. Keep this in mind when referencing the following table, as this information was pulled from this file, and their supported HTML tags could be subject to change.
Category | HTML Tag | Description |
---|---|---|
Basic Text Styling | <b> , <strong> |
Bold text |
<i> , <em> |
Italic text | |
<u> |
Underline text | |
<s> , <strike> , <del> |
Strikethrough text | |
<sup> |
Superscript text | |
<sub> |
Subscript text | |
<tt> |
Monospace text | |
Size/Font | <big> , <small> |
Relative text size changes |
<font color="..."> |
Sets foreground color | |
<span> (with inline CSS) |
Inline styles (e.g., color, background) | |
Paragraph & Block | <p> , <div> |
Block-level sections |
<br> |
Line break | |
<blockquote> |
Quoted block | |
<ul> + <li> |
Unordered list with bullets | |
Headings | <h1> - <h6> |
Headings (various sizes) |
Links & Images | <a href="..."> |
Clickable link |
<img src="..."> |
Inline image | |
Other Inline | <em> , <strong> , <dfn> , <cite> |
Synonyms for italic or bold |
Setting up HTML push notifications
To render multicolor text in a push notification, you can update your braze.xml
or BrazeConfig
:
Add the following in your braze.xml
:
1
<bool translatable="false" name="com_braze_push_notification_html_rendering_enabled">true</bool>
Add the following in your BrazeConfig
:
1
2
3
4
BrazeConfig brazeConfig = new BrazeConfig.Builder()
.setPushHtmlRenderingEnabled(true)
.build();
Braze.configure(this, brazeConfig);
1
2
3
4
val brazeConfig = BrazeConfig.Builder()
.setPushHtmlRenderingEnabled(true)
.build()
Braze.configure(this, brazeConfig)