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

vibrate: false is ignored #1140

Closed
robert599 opened this issue Jul 18, 2019 · 21 comments
Closed

vibrate: false is ignored #1140

robert599 opened this issue Jul 18, 2019 · 21 comments
Assignees

Comments

@robert599
Copy link

robert599 commented Jul 18, 2019

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"]',  
    });
}`
@wesdewitte
Copy link

I'm also having this issue. Any update or progress?

@necto68
Copy link

necto68 commented Sep 5, 2019

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.

@cristianoccazinsp
Copy link
Contributor

Any chances we can get a few fixes pushed into the library?

@pdpino
Copy link

pdpino commented Oct 24, 2019

@necto68 Do you have the links on docs about that android bug? github issue, docs, or anything.
That code solution didn't work for me

@teddyxfire
Copy link

@necto68 tnx, this solution works on my Google Pixel (Android 10).

If someone can't get this solution to work, make sure to clear the app data or reinstall the app after you update the RNPushNotificationHelper.java - if I understand correctly, changes to vibration pattern (or any changes related to notification channels) require clean start.

@phamhuuan
Copy link

phamhuuan commented Feb 27, 2020

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.
@necto68 Can you show me your RNPushNotificationHelper.java?
Thank you!

@Dallas62
Copy link
Collaborator

Dallas62 commented Apr 9, 2020

Hi!
A PR is welcome, I will take a look ASAP!

@maxtotallycodes
Copy link

Any updates on pushing a fix for the library? I'm having this issue with my app as well.

@Dallas62
Copy link
Collaborator

Hi @maxtotallycodes
I will take a look to this issue ASAP.
Since I don't have a Android phone available currently to test, a PR is welcome !

@Dallas62 Dallas62 self-assigned this Apr 20, 2020
@maxtotallycodes
Copy link

Hey @Dallas62, it sounds like @necto68 has the fix above (#1140 (comment)). Unfortunately I'm not technical (the username is a bit tongue in cheek), but I'm investigating because my team is having this issue.

@Dallas62
Copy link
Collaborator

I check this fix but it's not so easy...
When the channel is created, you can not update it anymore. So if we apply this settings once, you will have the same behaviour for all notifications. To get remote notification you need a default channel, which is a problem this there is no easy way to manage channel with the library.
I think we should refactor the library to implement a complement management of channels, it will be exclusive to Android but might answer to all those problems.

@maxtotallycodes
Copy link

How much work would a refactor like that be? My team (and I'm sure many others) would be okay with a clunkier solution in the short term that requires some work on our end because right now we're buzzing all our users phones when we really shouldn't be and driving them nuts. Even if it's not a perfect solution, anything would be great!

@Dallas62
Copy link
Collaborator

Hi @maxkomarychev
I will try to start this part tomorrow if there is not too many issues open this night 🤣

@maxtotallycodes
Copy link

Thank you! 🙏 We'll cross our fingers!

@Dallas62
Copy link
Collaborator

Hi @maxtotallycodes a new release is available with a fix on vibrate.
I took a look on the work for Android Channel, and wix/react-native-notifications seems to handle it, but they don't have scheduled notification. I think it's better to work with them to implement scheduled notifications, than refactor this library.

@maxtotallycodes
Copy link

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?

@Dallas62
Copy link
Collaborator

Dallas62 commented May 1, 2020

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.

@maxtotallycodes
Copy link

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

@Dallas62 Dallas62 closed this as completed May 2, 2020
@cristianoccazinsp
Copy link
Contributor

Hello,

After upgrading to 3.3.1 from 3.2.1, I'm getting "Default FirebaseApp is not initialized in this process. Make sure to call FirebaseApp.initializeApp(Context) first."

I am not using remote notifications nor firebase, why am I getting this?

@Dallas62
Copy link
Collaborator

Dallas62 commented May 8, 2020

Hi @clintonjrobinson
This issue has already been answered and README.md is up to date.

@viveKing21
Copy link

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.

where this file located at??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants