简体   繁体   中英

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

在此处输入图片说明

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',

 });

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

I have figured it out using the capacitor local notifications on any version of Android. To get the sound working you must create a channel. The link to all information about this is https://github.com/ionic-team/capacitor/issues/1146 When you get there checkout the comment made under @moderntechllc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM