OneSignal Help & Documentation

Welcome to the OneSignal New IA developer hub. You'll find comprehensive guides and documentation to help you start working with OneSignal New IA as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Discussions

Android Customizations

Customizing Android mobile app notifications with your app icons, colors, and style.

🚧

Android Mobile App Notifications Only

This section is for Android Mobile app customizations only. If you have a website, please see our Web Push Customizations guide.

Custom Notification Icons

Read more on the Android Notification Icons page.


Notification Categories

Notification categories are a new Android Oreo (8.0) feature which gives users finer control over notifications. You can select a category from Android Options or API android_channel_id when Sending Push Messages. To learn more about how Android Categories see Android Notification Categories.


Action Buttons

Android 4.1 and newer devices support actions buttons. You can specify up to 3 buttons that will display below your notification content. See Action Buttons.


Big Picture

See Images & Rich Media.


Background Images

Option to add a background image to your notifications.

🚧

Important limitations

  1. Android 12+ is changing the "Customizable Area" within notifications. So background images will look different and we recommend creating your own custom layout to handle this. Please review Android 12 Behavior Changes for details.

  2. The Android Background Layout does not support different Android Themes.

  3. The small and large icons will be overridden by the background image. Include it as part of your image if you need it to show still.

  4. Big Pictures will not work with Background Images.

  5. Our SDK does not provide an expanded view that supports multiline text. However you can create your own by following Google's Custom View Documentation.

You can add a background image to your Google Android Mobile App notifications by adding an image file named onesignal_bgimage_default_image to your res/drawable-xxxhdpi folder.

The size should be 2600x256 (91.4:9) to fit all devices including landscape mode.
(Such as the Samsung Galaxy S7)
In portrait mode the user may only see 1280x256 (5:1) on some devices so do design your image accordingly.

Use onesignal_bgimage_notif_title_color and onesignal_bgimage_notif_body_color in your values/colors.xml to set text colors to match your image.

Example color.xml file. Title is set to red and the body is set to green below.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="onesignal_bgimage_notif_title_color">#FFFF0000</color>
    <color name="onesignal_bgimage_notif_body_color">#FF00FF00</color>
</resources>

The image by default will be top left aligned, you may change it to be right aligned by setting the key onesignal_bgimage_notif_image_align to right in your strings.xml.
Example:

<resources>
    <string name="onesignal_bgimage_notif_image_align">right</string>
</resources>

In additional to locally setting the image in your app, it can be with the android_background_layout field through the Create notification REST API call.

The image can be a resource set within the app or an external URL with direct link to the image resource.


LED Color

Certain Android hardware devices have LED notification lights built-in, allowing notifications to trigger a colored notification light on a device upon receipt. Notification colors may be set on a per-message basis in the OneSignal dashboard, or via the OneSignal SDK/API.

Notification colors are set using ARGB Hex values (e.g. a red LED notification light would be in the format FF99000). If LED Color is not set, the light uses the device's default color.


Accent Color

Accent colors only apply to apps targeting Android API level 21+ running on Android 5.0+ devices.

Accent colors are the background color around your small icon, which appears to the left of the notification content in a notification. Like LED Colors, accent colors may be set with an ARGB Hex value in either the dashboard or SDK/API. If Accent Color is not set, the color is set to grey. Read more in Android Notification Icons


Notification Grouping

Android supports grouping or combining notifications together.

See Notification Grouping for more details.


App Icon Badge Counts

The OneSignal SDK automatically sets the badge count on your app to the number of notifications that are currently in the notification shade. If you want to disable this you can add the following to your AndroidManifest.xml.

See our Android Badges Guide for more details.


Notification Sounds

Read more in Customize Notification Sounds


Background Data and Notification Overriding

OneSignal supports sending additional data along with a notification as key value pairs. You can read this additional data when a notification is opened by adding a setNotificationOpenedHandler instead.

However, if you want to one of the following...

  • Receive data in the background with or without displaying a notification.
  • Override specific notification settings depending on client-side app logic such as custom accent color, vibration pattern, or other any other NotificationCompat options available. See Android's documentation on the NotificationCompat options.

...continue with the instructions in our Service Extensions Setup.


Resume last Activity when opening a Notification

Add the following code to the top of onCreate in your launcher Activity.

private static boolean activityStarted;

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  if (   activityStarted
      && getIntent() != null
      && (getIntent().getFlags() & Intent.FLAG_ACTIVITY_REORDER_TO_FRONT) != 0) {
    finish();
    return;
  }
  
  activityStarted = true;
}

Additional information:
By default OneSignal calls startActivity with the following intent flags.

Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK

Changing the open action of a notification

By default OneSignal will open or resume your launcher Activity when a notification is tapped on. You can disable this behavior by adding the meta-data tag com.onesignal.NotificationOpened.DEFAULT set to DISABLE inside your application tag in your AndroidManifest.xml.

<application ...>
   <meta-data android:name="com.onesignal.NotificationOpened.DEFAULT" android:value="DISABLE" />
</application>

Make sure you are initializing OneSignal with setNotificationOpenedHandler in the onCreate method in your Application class. You will need to call startActivity from this callback. See example setNotificationOpenedHandler method.

🚧

This disables the Launch URL

This will stop the OneSignal Launch URL from opening a URL in an in-app browser. You will need to open URLs with your own webview.

Preventing Multiple Instances of the same Activity

To prevent more than one copy of your Activity from running add android:launchMode="singleTask" to your Activity in your AndroidManifest.xml.

<activity
          android:name=".MainActivity"
          android:label="OneSignal Example"
          android:launchMode="singleTask" />

Right-to-Left (RTL) Notification Support

To support notifications with right-to-left languages correctly you must add android:supportsRtl="true" to your <application> tag in your AndroidManifest.xml.

<application
             android:supportsRtl="true"
             android:icon="@drawable/ic_launcher"
             android:theme="@style/AppTheme"
             android:label="OneSignal Example"
             android:name=".OneSignalExampleApp">
     ...
  </application>

Note, make sure to test all your Activities as this effect all views in your app.

Updated about a month ago


What's Next

Learn about setting up more features, or start using the OneSignal Dashboard

Features Setup
Dashboard

Android Customizations


Customizing Android mobile app notifications with your app icons, colors, and style.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.