I'm using Urban Airship push notification plugin in android. Everything working fine but in above Android 4.4 push notification icon is become white and not showing notification icon. This issue is only in Lolypop (>4.4). Any help is appreciated thanks.
It appears that apps that target SDK 21 (Lollipop) icons are automatically filtered to white - Notification bar icon turns white in Android 5 Lollipop. So to fix this, you can either set the target SDK version to 20, or you can manually modify the Urban Airship phonegap plugin and set the icon manually by replacing the execute method in https://github.com/urbanairship/phonegap-ua-push/blob/master/src/android/PushAutopilot.java with the following:
@Override
public void execute(final Application application) {
// Parse cordova config options
AirshipOptions configOptions = new AirshipOptions(application);
final boolean enablePushOnLaunch = configOptions.getBoolean(ENABLE_PUSH_ONLAUNCH, false);
UAirship.takeOff(application, getAirshipConfig(application, configOptions), new UAirship.OnReadyCallback() {
@Override
public void onAirshipReady(UAirship airship) {
// Create a new notification factory
DefaultNotificationFactory defaultNotificationFactory = new DefaultNotificationFactory(application);
// Customize the notification icon and accent color
defaultNotificationFactory.setSmallIconId(R.drawable.ic_notification);
defaultNotificationFactory.setColor(NotificationCompat.COLOR_DEFAULT);
// Set the factory
airship.getPushManager().setNotificationFactory(defaultNotificationFactory);
if (enablePushOnLaunch) {
airship.getPushManager().setUserNotificationsEnabled(true);
}
}
});
}
Replace the R.drawable_ic_notification
with an icon you included in your project.
Update: Released 3.0.0 of the plugin that allows you to specify the accent color and drawable name in the config without modifying any code.
<!-- Override the Android notification icon -->
<preference name="com.urbanairship.notification_icon" value="ic_notification" />
<!-- Specify the notification accent color for Android API 21+ (Lollipop) -->
<preference name="com.urbanairship.notification_accent_color" value="#0000ff" />
More info can be found here - https://github.com/urbanairship/phonegap-ua-push
© 2022 - 2024 — McMap. All rights reserved.