Skip to content

Commit

Permalink
feat(android): add vibration option to notifications channel (#2787)
Browse files Browse the repository at this point in the history

Co-authored-by: jcesarmobile <[email protected]>
  • Loading branch information
aren1989 and jcesarmobile authored May 7, 2020
1 parent 8de0414 commit 2f6f0ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public NotificationChannelManager(Context context, NotificationManager manager)
private static String CHANNEL_IMPORTANCE = "importance";
private static String CHANNEL_VISIBILITY = "visibility";
private static String CHANNEL_SOUND = "sound";
private static String CHANNEL_VIBRATE = "vibration";
private static String CHANNEL_USE_LIGHTS = "lights";
private static String CHANNEL_LIGHT_COLOR = "lightColor";

Expand All @@ -50,6 +51,7 @@ public void createChannel(PluginCall call) {
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));
channel.put(CHANNEL_LIGHT_COLOR, call.getString(CHANNEL_LIGHT_COLOR, null));
createChannel(channel);
Expand All @@ -63,6 +65,7 @@ public void createChannel(JSObject channel) {
NotificationChannel notificationChannel = new NotificationChannel(channel.getString(CHANNEL_ID), channel.getString(CHANNEL_NAME), channel.getInteger(CHANNEL_IMPORTANCE));
notificationChannel.setDescription(channel.getString(CHANNEL_DESCRIPTION));
notificationChannel.setLockscreenVisibility(channel.getInteger(CHANNEL_VISIBILITY));
notificationChannel.enableVibration(channel.getBool(CHANNEL_VIBRATE));
notificationChannel.enableLights(channel.getBool(CHANNEL_USE_LIGHTS));
String lightColor = channel.getString(CHANNEL_LIGHT_COLOR);
if (lightColor != null) {
Expand Down Expand Up @@ -109,6 +112,7 @@ public void listChannels(PluginCall call) {
channel.put(CHANNEL_IMPORTANCE, notificationChannel.getImportance());
channel.put(CHANNEL_VISIBILITY, notificationChannel.getLockscreenVisibility());
channel.put(CHANNEL_SOUND, notificationChannel.getSound());
channel.put(CHANNEL_VIBRATE, notificationChannel.shouldVibrate());
channel.put(CHANNEL_USE_LIGHTS, notificationChannel.shouldShowLights());
channel.put(CHANNEL_LIGHT_COLOR, String.format("#%06X", (0xFFFFFF & notificationChannel.getLightColor())));
Logger.debug(Logger.tags("NotificationChannel"), "visibility " + notificationChannel.getLockscreenVisibility());
Expand Down
1 change: 1 addition & 0 deletions core/src/core-plugin-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,7 @@ export interface NotificationChannel {
visibility?: -1 | 0 | 1 ;
lights?: boolean;
lightColor?: string;
vibration?: boolean;
}

export interface NotificationChannelList {
Expand Down

0 comments on commit 2f6f0ba

Please sign in to comment.