Skip to content

Commit 7111463

Browse files
milos1290Enuviel
authored andcommitted
feat(channels): check if notifications are supported (#90)
1 parent 0c60c9e commit 7111463

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

AndroidSDK/src/com/leanplum/Leanplum.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -736,21 +736,23 @@ protected Void doInBackground(Void... params) {
736736
Log.d("No variants received from the server.");
737737
}
738738

739-
// Get notification channels and groups.
740-
JSONArray notificationChannels = response.optJSONArray(
741-
Constants.Keys.NOTIFICATION_CHANNELS);
742-
JSONArray notificationGroups = response.optJSONArray(
743-
Constants.Keys.NOTIFICATION_GROUPS);
744-
String defaultNotificationChannel = response.optString(
745-
Constants.Keys.DEFAULT_NOTIFICATION_CHANNEL);
746-
747-
// Configure notification channels and groups
748-
LeanplumNotificationChannel.configureNotificationGroups(
749-
context, notificationGroups);
750-
LeanplumNotificationChannel.configureNotificationChannels(
751-
context, notificationChannels);
752-
LeanplumNotificationChannel.configureDefaultNotificationChannel(
753-
context, defaultNotificationChannel);
739+
if (LeanplumNotificationChannel.isNotificationChannelSupported(context)) {
740+
// Get notification channels and groups.
741+
JSONArray notificationChannels = response.optJSONArray(
742+
Constants.Keys.NOTIFICATION_CHANNELS);
743+
JSONArray notificationGroups = response.optJSONArray(
744+
Constants.Keys.NOTIFICATION_GROUPS);
745+
String defaultNotificationChannel = response.optString(
746+
Constants.Keys.DEFAULT_NOTIFICATION_CHANNEL);
747+
748+
// Configure notification channels and groups
749+
LeanplumNotificationChannel.configureNotificationGroups(
750+
context, notificationGroups);
751+
LeanplumNotificationChannel.configureNotificationChannels(
752+
context, notificationChannels);
753+
LeanplumNotificationChannel.configureDefaultNotificationChannel(
754+
context, defaultNotificationChannel);
755+
}
754756

755757
String token = response.optString(Constants.Keys.TOKEN, null);
756758
Request.setToken(token);

0 commit comments

Comments
 (0)