-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Added Android 8 Support for Sound and Vibrate properties. #1696
Added Android 8 Support for Sound and Vibrate properties. #1696
Conversation
Created ability to have multiple channels generated dynamically for vibrate/sound configurations. * removed extra changes caused by creating a new branch *
@timkellypa Thanks for this! But if I set different sounds for each notification, only the first sound that was set plays. Is it something to do with the channel being created only once at the beginning? Any way to fix? Edit:
And added this:
Just to make sure the channel is created. See my repo that I cloned from you and made the changes on: https://github.com/sanctus671/cordova-plugin-local-notifications. Now you can create different channels to play different sounds by making sure the channel property is set when you create the notification. |
@sanctus671 Yes, I was missing that case. I may end up just changing it to optionally pass in the channel ID (like it does the channel name) to createChannelWithOptions (that way everything filters through one function). But yeah, basically making new channels is the only way to go for this to work. Once you create one, it can't be updated. Glad you got it working! |
Trying the code in https://github.com/sanctus671/cordova-plugin-local-notifications (also tried the the code in the beggining) but the sound still doesnt play for me. Wondering if anything changed in the setup of the notification for Android 8 in this plugin ? |
@TLMNicolas I think it needs to be .mp3 for Android. Try testing with an mp3 file and see if that works. If not, can you paste the code you are using the schedule the notification? I'll see if anything sticks out to me as being a problem. |
@TLMNicolas , @sanctus671 is correct. It needs to be an MP3 to work. If you have a wav file, you can just download LAME to convert it easily. |
Appreciate the help. I traditionally have used .wav for notifications because it worked on ios and android so it meant i only had to keep 1 file instead of multiple, and deal with naming and such. Tried using an mp3. Placed it in two places,
Then in the code i tried multiple variations In adb/logcat i see something like this (when using res://rooster.mp3) No luck, still plays default sound. (On ios its fine with res://rooster.wav) Edit: |
(edited after re-reading your post, since I see you answered my question about assets) @TLMNicolas I don't mind continuing this conversation in this thread. For my application, I've only used "file://". You want the path from "file" to start at the root of the actual JavaScript code in the "www" directory in the cordova project. So file://assets/sounds/rooster.mp3 was correct. Another thing to note, and anybody using this plugin should know this: When an Android 8 notification channel is created, it cannot be modified by the app. So, if you are installing over your existing app without completely uninstalling it first, it will continue playing the default sound, even if you fix the configuration, add new alarms, etc. |
I appreciate your effort @timkellypa and @sanctus671 |
@sanctus671 Just for an update, I addressed your issue for multiple channel support (now you can pass a channelId, and it'll use that when it creates your channel, instead of the one it generates), but unfortunately the tip of development for me is part of a new pull request, with another feature I needed for my app (auto launch): This pull request contains all of the code in this branch, and extends it for auto-launch functionality (which is optional and not a default, so you should be able to use it without issue). I apologize for not keeping my code more organized and keeping these pull requests separated as I should have. Everything's kind of intertwined, and my particular use case has some very specific requirements. |
Created ability to have multiple channels
generated dynamically for vibrate/sound configurations.