Urban Airship notification icon in Android 4.4 with PhoneGap

I am using the Urban Airship Android notification plugin. Everything works fine, but on the notification icon Android 4.4 4.4 turns white and the notification icon does not appear. This problem exists only in Lolypop (> 4.4). Any help is appreciated.

enter image description here

+5
source share
1 answer

It looks like apps designed for SDK 21 (Lollipop) icons are automatically filtered to white - The notification bar icon turns white in Android 5 Lollipop . Therefore, to fix this, you can either set the target version of the SDK to 20, or manually change the phonegap Urban Airship plugin and install the icon manually, 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 R.drawable_ic_notification with the icon that you included in your project.

Update: A 3.0.0 plugin has been released that allows you to specify the accent color and the assigned name in the config without changing 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 information can be found here - https://github.com/urbanairship/phonegap-ua-push

+6
source

Source: https://habr.com/ru/post/1216053/


All Articles