Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit b89eb22

Browse files
author
Nesh Patel
committed
This fixes the vibration feature for notification for Android notifications for API >= 26. This pattern is used for the Notif Builder for API < 26 and it appears to work there as well.
Before: ``` <Sending Notif> 2020-10-04 12:37:03.630 1936-29464/? E/VibratorService: vibratorOff command failed (1). 2020-10-04 12:37:03.935 1936-29476/? E/VibratorService: vibratorOff command failed (1). ``` After: ``` <Sending Notif> 2020-10-04 12:07:16.037 1936-4760/? E/VibratorService: vibratorOff command failed (1). 2020-10-04 12:07:16.037 1936-4760/? E/VibratorService: vibratorOn command failed (1). 2020-10-04 12:07:16.438 1936-1936/? E/VibratorService: vibratorOff command failed (1). ``` Have tested this on a physical device as well and it works. This could lead to an obvious extension which is for users to specify a vibration pattern array when creating a channel.
1 parent 60883d1 commit b89eb22

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ public boolean createChannel(ReadableMap channelInfo) {
908908
String soundName = channelInfo.hasKey("soundName") ? channelInfo.getString("soundName") : "default";
909909
int importance = channelInfo.hasKey("importance") ? channelInfo.getInt("importance") : 4;
910910
boolean vibrate = channelInfo.hasKey("vibrate") && channelInfo.getBoolean("vibrate");
911-
long[] vibratePattern = vibrate ? new long[] { DEFAULT_VIBRATION } : null;
911+
long[] vibratePattern = vibrate ? new long[] { 0, DEFAULT_VIBRATION } : null;
912912

913913
NotificationManager manager = notificationManager();
914914

0 commit comments

Comments
 (0)