Android Oreo及以上版本无法播放离子推送通知自定义声音

问题描述 投票:0回答:1

根据push插件的Ionic文档,我为android O及以上版本创建了Channel。参考链接: -

https://ionicframework.com/docs/native/push/

我实际上想要在收到推送通知时播放自定义声音,并且它已经在Android 7(牛轧糖)及以下版本上运行,但我在Android Oreo及以上版本上遇到问题,推送通知正在接收,但不会播放自定义声音。我提到了很多链接来解决这个问题,但没什么可行的。

参考链接: -

https://github.com/phonegap/phonegap-plugin-push/issues/2017

https://github.com/phonegap/phonegap-plugin-push/issues/2446

在大多数建议的解决方案中,他们建议在createChannel方法中添加“声音”参数,如下所示: -

this.push.createChannel({
id: "testchannel7",
description: "asdf",
sound: 'pulse',
// The importance property goes from 1 = Lowest, 2 = Low, 3 = Normal, 4 = High and 5 = Highest.
importance: 4,
vibration: true
}).then(() => console.log('Channel created'));

但我得到了

打字稿错误: - Typescript错误类型'{id:string;描述:字符串;重要性:3;声音:字符串; }'不能分配给'Channel'类型的参数。对象文字只能指定已知属性,“声道”类型中不存在“声音”。

甚至我将我的sound.mp3文件存储在以下位置: - platforms / android / app / src / main / res / raw

在我的有效载荷声音参数已添加没有扩展名,如: -

{
...,
...,
sound: soundname,
...
}

我的离子环境配置: -

离子型:

离子(离子CLI):4.5.0(/ usr / local / lib / node_modules / ionic)

离子框架:离子角3.9.2

@ ionic / app-scripts:3.1.6

科尔多瓦:

cordova(Cordova CLI):8.1.2([email protected]

Cordova平台:android 7.1.4

Cordova插件:cordova-plugin-ionic-webview 3.1.1

Push Plugin版本: -

phonegap-plugin-push 2.2.3“PushPlugin”

请帮我解决这个问题,提前谢谢。

android cordova ionic-framework push-notification phonegap
1个回答
0
投票

我遇到了和你一样的问题,并将@ ionic-native / push更新为4.20.0

npm install --save @ionic-native/[email protected]

为我工作。

希望这对你有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.