Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): add vibration option to notifications channel #2787

Merged
merged 2 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,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 @@ -54,6 +55,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 @@ -67,6 +69,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 @@ -113,6 +116,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())));
Log.d(TAG, "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 @@ -1574,6 +1574,7 @@ export interface NotificationChannel {
visibility?: -1 | 0 | 1 ;
lights?: boolean;
lightColor?: string;
vibration?: boolean;
}

export interface NotificationChannelList {
Expand Down