Urban Airship recommends creating a custom notification with CustomPushNotificationBuilder
if you want to make any modifications to the status bar notification, including trivially changing the icon.
Unfortunately, using a RemoteView
for notifications carries many unwanted implications with it related to custom manufacturer and/or platform-specific skins, including text colors and references to private resources (for instance @*android:drawable/notify_panel_notification_icon_bg_tile
on Honeycomb/ICS).
There must be a simple way to swap the icon without using RemoteView
. How?
I found that by overriding
BasicPushNotificationBuilder
, I can set the icon quite trivially:I know this is an old question, but UrbanAirship get's updated quite often, so I decided to help others who might reach this page. As of version 6.0.1 there's no
BasicNotificationBuilder
no more. In order to customize your notification with icon and color and whatnot, you need to extend theNotifcationFactory
class, and override thecreateNotification
method.Like shown in the example below:
}
At last you must set this as UrbanAirship's new notification factory in your application class or wherever you initialized UA:
We provide a lot of functionality in our default notification factory such as big styles (inbox, text, image), lollipop features (privacy, priority), and interactive notification buttons. If you are only trying to set the icon and maybe the accent color, I recommend the following:
Full docs on the class can be found here - http://docs.urbanairship.com/reference/libraries/android/latest/reference/com/urbanairship/push/notifications/DefaultNotificationFactory.html