OneSignal通知自定义声音不起作用

时间:2019-03-29 15:11:34

标签: ionic-framework onesignal

我通过OneSignal插件在我的应用中增加了通知,我想自定义通知的声音,我遵循了文档,但没有用。

这是我正在使用的代码:

    var notification = new OneSignal.Notification({
    contents: {
        ar: req.body.title,
        en: req.body.titleEn,
    },
    include_player_ids: req.body.includePlayersIds,
    data: req.body.data,
    send_after: req.body.sendAfter,
    delayed_option: "timezone",
    android_sound: "sahwah",
    ios_sound: "sahwah.wav"
});

我已经将名为sahwah的声音文件放在此路径下:/ platforms / android / res / raw /

可能是什么问题?

1 个答案:

答案 0 :(得分:0)

有几种原因可能导致您无法播放声音:

  • 声音文件可能太长了
  • 通过提取声音文件并确保其位于res / raw /中,确保声音文件已内置到APK中。

如果启用了资源缩减功能,则可以使用以下代码在res / raw /中创建keep.xml,以防止声音文件被删除:

<resources xmlns:tools="http://schemas.android.com/tools" tools:keep="@raw/sound_file"/>

相关问题