Skip to content

Commit 92c4c20

Browse files
committed
Channel payload boolean to integer format change
1 parent 98a8c7f commit 92c4c20

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/NotificationChannelManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ private static String createChannel(Context context, NotificationManager notific
122122
channel.setGroup(group_id);
123123
}
124124

125-
channel.enableLights(payload.optBoolean("led", true));
125+
channel.enableLights(payload.optInt("led", 1) == 1);
126126
if (payload.has("ledc")) {
127127
BigInteger ledColor = new BigInteger(payload.optString("ledc"), 16);
128128
channel.setLightColor(ledColor.intValue());
129129
}
130130

131-
channel.enableVibration(payload.optBoolean("vib", true));
131+
channel.enableVibration(payload.optInt("vib", 1) == 1);
132132
if (payload.has("vib_pt")) {
133133
JSONArray json_vib_array = payload.optJSONArray("vib_pt");
134134
long[] long_array = new long[json_vib_array.length()];
@@ -151,8 +151,8 @@ else if ("null".equals(sound) || "nil".equals(sound))
151151
// Otherwise not calling setSound makes it the default notification sound.
152152

153153
channel.setLockscreenVisibility(payload.optInt("vis", Notification.VISIBILITY_PUBLIC));
154-
channel.setShowBadge(payload.optBoolean("bdg", true));
155-
channel.setBypassDnd(payload.optBoolean("bdnd", false));
154+
channel.setShowBadge(payload.optInt("bdg", 1) == 1);
155+
channel.setBypassDnd(payload.optInt("bdnd", 0) == 1);
156156

157157
notificationManager.createNotificationChannel(channel);
158158
return channel_id;

OneSignalSDK/unittest/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ dependencies {
7878
compile 'com.android.support:customtabs:26.0.0'
7979

8080
testCompile 'junit:junit:4.12'
81-
testCompile 'org.robolectric:robolectric:3.4'
81+
testCompile 'org.robolectric:robolectric:3.4.2'
8282
}

OneSignalSDK/unittest/src/test/java/com/test/onesignal/NotificationChannelManagerRunner.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ public void createNotificationChannelWithALlOptions() throws Exception {
105105
chnl.put("grp_nm", "Group Name");
106106

107107
payload.put("pri", 10);
108-
payload.put("led", false);
108+
payload.put("led", 0);
109109
payload.put("ledc", "FFFF0000");
110-
payload.put("vib", false);
110+
payload.put("vib", 0);
111111
payload.put("vib_pt", new JSONArray("[1,2,3,4]"));
112112
payload.put("sound", "notification");
113113
payload.put("vis", Notification.VISIBILITY_SECRET);
114-
payload.put("bdg", true);
115-
payload.put("bdnd", true);
114+
payload.put("bdg", 1);
115+
payload.put("bdnd", 1);
116116

117117
payload.put("chnl", chnl);
118118

0 commit comments

Comments
 (0)