Urban Airship 推送通知图标在上面 Android 4.4 with PhoneGap
Urban Airship push notification icon in above Android 4.4 with PhoneGap
我在 android 中使用 Urban Airship 推送通知插件。一切正常,但在 Android 4.4 以上推送通知图标变为白色且不显示通知图标。此问题仅在 Lolypop (>4.4) 中存在。感谢任何帮助。
以 SDK 21 (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 具有以下内容:
@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);
}
}
});
}
将 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" />
可以在此处找到更多信息 - https://github.com/urbanairship/phonegap-ua-push
我在 android 中使用 Urban Airship 推送通知插件。一切正常,但在 Android 4.4 以上推送通知图标变为白色且不显示通知图标。此问题仅在 Lolypop (>4.4) 中存在。感谢任何帮助。
以 SDK 21 (Lollipop) 为目标的应用程序图标似乎会自动过滤为白色 -
@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);
}
}
});
}
将 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" />
可以在此处找到更多信息 - https://github.com/urbanairship/phonegap-ua-push