Skip to content

Commit

Permalink
add more specific channelId error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
pwilkniss committed May 24, 2019
1 parent bfe94f4 commit b4fce58
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5484,10 +5484,16 @@ private void triggerNotification(Context context, Bundle extras, String notifMes
}

String channelId = extras.getString(Constants.WZRK_CHANNEL_ID, "");
boolean requiresChannelId = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (channelId.isEmpty() || notificationManager.getNotificationChannel(channelId) == null) {
String channelIdError = "Unable to render notification, channelId is required but is wrong/not provided in the notification payload: " + extras.toString();
String channelIdError = null;
if (channelId.isEmpty()) {
channelIdError = "Unable to render notification, channelId is required but not provided in the notification payload: " + extras.toString();
} else if (notificationManager.getNotificationChannel(channelId) == null) {
channelIdError = "Unable to render notification, channelId: " + channelId + " not registered by the app.";
}
if (channelIdError != null) {
getConfigLogger().debug(getAccountId(), channelIdError);
pushValidationResult(new ValidationResult(512, channelIdError));
return;
Expand Down Expand Up @@ -5587,7 +5593,7 @@ private void triggerNotification(Context context, Bundle extras, String notifMes
}

NotificationCompat.Builder nb;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (requiresChannelId) {
nb = new NotificationCompat.Builder(context, channelId);

// choices here are Notification.BADGE_ICON_NONE = 0, Notification.BADGE_ICON_SMALL = 1, Notification.BADGE_ICON_LARGE = 2. Default is Notification.BADGE_ICON_LARGE
Expand Down

0 comments on commit b4fce58

Please sign in to comment.