Personalized sound in Cordova Local Notification

Asked

Viewed 377 times

2

I’m trying to customize the sound for a notification using the Cordova. I am using the plugin Cordova Local Notification, but the sound is not played when displaying the notification.

Tests carried out:

  • I tried using custom sound on SDCard: worked!
  • I tried to use the sound by a URL: didn’t work, but it’s not what I need
  • I tried to use a sound that stays in the folder www called beep.mp3: didn’t work, and that’s what I need

Tests carried out on Android, more precise to work on iOS also.

Below is the code I’m trying to implement:

window.plugin.notification.local.add({
            id: id,
            title: titulo,
            message: msg,
            sound: (config.platform_compilation != 'IOS') ? 'file:///android_assets/www/beep.mp3' : 'www/audio/beep.mp3',
            date: DateOBJ
});

My verification of the config.platform_compilation is correct, the problem is when you try to play the sound that is in www, if I put this file in the SDCard and I change the path at compilation time, it works, but I need that sound inside the APK/APP to make available.

1 answer

1

With the plugin update the sound came back to work, I just needed to remove it and put again.

Below is an example of the use:

window.plugin.notification.local.add({
        id: id,
        title: titulo,
        message: msg,
        sound: (config.platform_compilation != 'IOS') ? 'file:///beep.mp3' : 'www/beep.mp3',
        date: DateOBJ
});

The file is in /android_asset/www .

Browser other questions tagged

You are not signed in. Login or sign up in order to post.