简体   繁体   English

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

[英]Urban Airship push notification icon in above Android 4.4 with PhoneGap

I'm using Urban Airship push notification plugin in android. 我在android中使用Urban Airship推送通知插件。 Everything working fine but in above Android 4.4 push notification icon is become white and not showing notification icon. 一切正常,但在上面的Android 4.4推送通知图标变为白色,没有显示通知图标。 This issue is only in Lolypop (>4.4). 此问题仅在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 . 看起来针对SDK 21(Lollipop)图标的应用程序会自动过滤为白色 - 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: 因此,要解决此问题,您可以将目标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);
            }
        }
    });
}

Replace the R.drawable_ic_notification with an icon you included in your project. R.drawable_ic_notification替换为R.drawable_ic_notification包含的图标。

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. 更新:发布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" />

More info can be found here - https://github.com/urbanairship/phonegap-ua-push 更多信息可以在这里找到 - https://github.com/urbanairship/phonegap-ua-push

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM