katzer / cordova-plugin-local-notifications

Cordova Local-Notification Plugin
Apache License 2.0
2.56k stars 1.74k forks source link

Default notification sound plays on Android no matter what #1553

Open wodim opened 6 years ago

wodim commented 6 years ago

WARNING: IF YOU IGNORE THIS TEMPLATE, WE'LL IGNORE YOUR ISSUE. YOU MUST FILL THIS IN!

Provide a general summary of the issue.

Your Environment

Expected Behavior

Whatever sound I choose to play should play, or none at all if I choose sound: null or something like that

Actual Behavior

I always get the default notification sound from Android

Steps to Reproduce

        cordova.plugins.notification.local.schedule({
            id:         1337,
            title:      "xxx",
            text:       "xxx",
            sticky:     true,
            autoClear:  false,
            sound:      "file://empty.mp3",
            vibrate:    false,
        });

Or...

        cordova.plugins.notification.local.schedule({
            id:         1337,
            title:      "xxx",
            text:       "xxx",
            sticky:     true,
            autoClear:  false,
            sound:      null,
            vibrate:    false,
        });
wodim commented 6 years ago

This only seems to happen when you run the app on Oreo. I just tested it on Nougat and no sound plays, as expected. Didn't try a custom sound, though.

ggutenberg commented 6 years ago

Confirmed that this issue occurs with a custom sound as well.

albertleao commented 6 years ago

Any updates to this?

MInesGomes commented 4 years ago

I have the same problem. https://github.com/ionic-team/ionic/issues/19696

and it seems missing the "channel" as described here https://distriqt.github.io/ANE-PushNotifications/m.FCM-GCM%20Payload

Sounds on individual notifications were deprecated in Android O (API 26). You now have to set them on a channel.

@wodim did you found a solution?

wodim commented 4 years ago

I don't remember what I did about this but if you know what the problem is that the "channel" is missing then you could edit the Java code of the plugin.

MInesGomes commented 4 years ago

@wodim Thanks for the reply ... I don't know the java code to implement the channel ... I have seen this ... https://stackoverflow.com/questions/53913251/different-notification-sound-not-working-in-oreo

I just know is necessary a different channel every time I launch a localNotification with a different sound .... If you find a solution I would be 😃