Search code examples
javascriptaudioionic-frameworkionic3uilocalnotification

Custom sound in local Notification IONIC 3


I want to change the default sound for local notification on android but it doesn't work

i tried to put the sound file into the project but when i run my app it play the default sound

enter image description here

also i tried to put on sound field a remote sound file but the same issue

this.localNotifications.schedule({
    text: 'Delayed ILocalNotification',
    at: new Date(new Date().getTime() + 3600),
    led: 'FF0000',
    sound: 'https://notificationsounds.com/soundfiles/15de21c670ae7c3f6f3f1f37029303c9/file-sounds-1085-definite.mp3',

 });

Solution

  • The sounds file where you placed is correct.

    But when you build the Android app, it's location is different.

    android_asset/www/assets/sounds/name.mp3
    

    That is the location you need to specify

    Of course this is used when you are using the media plugin, after the notification is received.

    EDIT This is no longer a viable solution. Refer docs for ionic, since there are ground breaking changes both in android and iOS