使用PhoneGap在Android 4.4上方的Urban Airship推送通知图标

Rit*_*ngh 6 android phonegap-pushplugin

我在android中使用Urban Airship推送通知插件.一切正常,但在上面的Android 4.4推送通知图标变为白色,没有显示通知图标.此问题仅在Lolypop(> 4.4)中.任何帮助表示赞赏谢谢.

在此输入图像描述

ral*_*ski 8

看起来针对SDK 21(Lollipop)图标的应用程序会自动过滤为白色 - Android 5 Lollipop中的通知栏图标变为白色.因此,要解决此问题,您可以将目标SDK版本设置为20,或者您可以手动修改Urban Airship phonegap插件并通过替换https://github.com/urbanairship/phonegap-ua中的execute方法手动设置图标-push/blob/master/src/android/PushAutopilot.java具有以下内容:

@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);
            }
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

替换为R.drawable_ic_notification项目中包含的图标.

更新:发布3.0.0的插件,允许您在配置中指定重音颜色和可绘制名称,而无需修改任何代码.

<!-- 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" />
Run Code Online (Sandbox Code Playgroud)

更多信息可以在这里找到 - https://github.com/urbanairship/phonegap-ua-push