react-native-push-notification: vibrate: false is ignored

Hi,

my settings disabling to vibrate function, but on each notification my device are still vibrating. It is a bug in your lib or have I a misconfiguration?

“react-native”: “^0.58.6” “react-native-push-notification”: “^3.1.3”

test-device: huawai p10 lite android: 8.0.0

my settings: `localNotif(message, item) { PushNotification.localNotification({ /* Android Only Properties */ id: ‘1’, autoCancel: true, largeIcon: “ic_launcher”, smallIcon: “ic_notification”, bigText: message, vibrate: false, // (optional) default: true vibration: 0, // vibration length in milliseconds, ignored if vibrate=false, default: 1000 itemData: item,

        /* iOS only properties */
        alertAction: 'view', 
        category: null, 
        userInfo: null, 

        /* iOS and Android properties */
        title: Localization('General.Download.DownloadTitle'), // (optional)
        message: message, // (required)
        playSound: false, // (optional) default: true
        soundName: 'default', 
        number: '10', 
        // actions: '["Yes", "No"]',  
    });
}`

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 11
  • Comments: 21 (2 by maintainers)

Most upvoted comments

This is a bug in Android 8+. You can fix it in RNPushNotificationHelper.java.

long vibration = bundle.containsKey("vibration") ? (long) bundle.getDouble("vibration") : DEFAULT_VIBRATION;
        long[] vibratePattern = (bundle.containsKey("vibrate") && bundle.getBoolean("vibrate")) ? new long[]{0, vibration} : new long[]{ 0 };

        channel.setDescription(this.config.getChannelDescription());
        channel.enableLights(true);

        channel.setVibrationPattern(vibratePattern);
        channel.enableVibration(true);

        manager.createNotificationChannel(channel);
        channelCreated = true;

Add this at the end of the file.

We tried out the new release and unfortunately it made all our notifications the silent kind that appear minimized at the bottom of the notification tray (and they’re only visible when you open the notification tray). 😦

If working with that other library is the best option, do we have code they could use for scheduled notifications?

Sorry for this issue, I fixed it on 3.3.1.

@Dallas62 that seemed to do the trick, thank you!