Skip to content

Commit

Permalink
fix(push-notifications): Throw errors if missing mandatory channel fi…
Browse files Browse the repository at this point in the history
…elds (#576)
  • Loading branch information
jcesarmobile committed Aug 30, 2021
1 parent 6bf3a4f commit 50f4e70
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,26 @@ public NotificationChannelManager(Context context, NotificationManager manager)
public void createChannel(PluginCall call) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
JSObject channel = new JSObject();
channel.put(CHANNEL_ID, call.getString(CHANNEL_ID));
channel.put(CHANNEL_NAME, call.getString(CHANNEL_NAME));
if (call.getString(CHANNEL_ID) != null) {
channel.put(CHANNEL_ID, call.getString(CHANNEL_ID));
} else {
call.reject("Channel missing identifier");
return;
}
if (call.getString(CHANNEL_NAME) != null) {
channel.put(CHANNEL_NAME, call.getString(CHANNEL_NAME));
} else {
call.reject("Channel missing name");
return;
}
if (call.getInt(CHANNEL_IMPORTANCE) != null) {
channel.put(CHANNEL_IMPORTANCE, call.getInt(CHANNEL_IMPORTANCE));
} else {
call.reject("Channel missing importance");
return;
}
channel.put(CHANNEL_DESCRIPTION, call.getString(CHANNEL_DESCRIPTION, ""));
channel.put(CHANNEL_VISIBILITY, call.getInt(CHANNEL_VISIBILITY, NotificationCompat.VISIBILITY_PUBLIC));
channel.put(CHANNEL_IMPORTANCE, call.getInt(CHANNEL_IMPORTANCE));
channel.put(CHANNEL_SOUND, call.getString(CHANNEL_SOUND, null));
channel.put(CHANNEL_VIBRATE, call.getBoolean(CHANNEL_VIBRATE, false));
channel.put(CHANNEL_USE_LIGHTS, call.getBoolean(CHANNEL_USE_LIGHTS, false));
Expand Down

0 comments on commit 50f4e70

Please sign in to comment.