【问题标题】:Monaca: custom notification sound and small icon in Android with OnesignalMonaca:使用 Onesignal 在 Android 中自定义通知声音和小图标
【发布时间】:2018-03-12 04:56:05
【问题描述】:

我已经启动了一个 Monaca 项目,导入了官方的 Onesignal 插件,它工作正常。

问题是我找不到在 Android 中发送自定义声音和小图标的方法。我在 /res/android/raw/ 下放置了一个 mp3 文件,在 /res/android/screen 中放置了一个纯白色的小图像,但它们没有被使用。

我尝试在通知中包含和排除文件扩展名,但无济于事。还尝试将文件放在项目的根目录上。

有没有人能够做到这一点?提前致谢。

【问题讨论】:

  • 你找到解决办法了吗?
  • 你找到什么了吗?

标签: android onesignal monaca


【解决方案1】:

在 config.xml 中添加类似的内容

<platform name="ios">
  <resource-file src="res/ios/sound/bird01.wav" />
  <hook type="before_compile" src="res/ios/sound/copy.js"/>
</platform>

在 copy.js 中(########### 是项目名称):

module.exports = function(ctx) {
    var fs = ctx.requireCordovaModule('fs'),
        path = ctx.requireCordovaModule('path'),
        deferral = ctx.requireCordovaModule('q').defer(),
        shell = ctx.requireCordovaModule('shelljs');

    var dest = path.join(ctx.opts.projectRoot, 'platforms/ios/###########.xcodeproj/Resources');
    var src = "res/ios/sound/*.*"
    shell.mkdir(dest)
    shell.cp(src, dest);
    console.log(shell.ls(dest));
    deferral.resolve();

    return deferral.promise;
}; 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-26
    • 1970-01-01
    相关资源
    最近更新 更多