Skip to content

Commit 239fcd8

Browse files
committed
feat(channel): fixing for potential NPE when createNotificationChannel return null.
1 parent 7b63194 commit 239fcd8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

AndroidSDK/src/com/leanplum/LeanplumPushService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,12 @@ private static void showNotification(Context context, Bundle message) {
328328
// Create channel if it doesn't exist and post notification to that channel.
329329
Map<String, Object> channelDetails = JsonConverter.fromJson(channel);
330330
String channelId = LeanplumNotificationChannel.createNotificationChannel(context, channelDetails);
331-
builder = new NotificationCompat.Builder(context, channelId);
331+
if (!TextUtils.isEmpty(channelId)) {
332+
builder = new NotificationCompat.Builder(context, channelId);
333+
} else {
334+
Log.w("Failed to post notification to specified channel.");
335+
return;
336+
}
332337
} else {
333338
// If channel isn't supplied, try to look up for default channel.
334339
String channelId = LeanplumNotificationChannel.getDefaultNotificationChannelId(context);

0 commit comments

Comments
 (0)