本地通知 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.

但是当你构建 Android 应用时,它的位置是不同的.

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

android_asset/www/assets/sounds/name.mp3

那是你需要指定的位置

当然这是在你使用media插件的时候,收到通知后使用的.

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

编辑这不再是一个可行的解决方案.请参阅 ionic 文档,因为在 android 和 iOS 中都有突破性的变化

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

相关文章