Ionic 4本地通知声音在Oreo +中不起作用

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

我正在构建Ionic 4应用,并且本地通知sound在牛轧糖中运行,但在Oero中不工作。只是播放默认声音,而忽略sound

我在这里阅读:https://distriqt.github.io/ANE-PushNotifications/m.FCM-GCM%20Payload

个别通知的声音在Android O(API 26)中已弃用。您现在必须将它们设置在频道上。

Different notification sound not working in Oreo

该频道是必需的

 this.localNot.schedule({
      id: id,
      // channel: id, // IS NOT Possible to set
      title: title,
      text: 'Some text',
      sound: `file://assets/audio/mySOUNDFILE.mp3`,
      icon: 'file://assets/img/logo/favicon.png', // TODO resident Img,
      color: colour
    });

但是就像我没有在离子领域提供“通道”一样,我在这里提出了一个问题,但是很接近。https://github.com/ionic-team/ionic/issues/19696

您有建议我该如何运作?

ionic-framework audio android-8.0-oreo localnotification
1个回答
0
投票

我正在使用“ git + https://github.com/Steffaan/cordova-plugin-local-notifications.git”,

home.ts

declare var cordova: Cordova;
@Component({
  selector: 'app-home', ...

并发送通知

    cordova.plugins.notification.local.schedule({
      id: Myid,
      title: tit,
      text: txt,
      priority: MyPriority,
      channel: 'MyChannel',
      sound: `file://assets/audio/${sound}.mp3`,
      foreground: true,
      lockscreen: true,
      vibrate: vib,
      wakeup: true,
    });

哪里

      priority: MyPriority,
      channel: 'MyChannel',

对于每个不同的声音,必须有所不同

在我设置的文件/node_modules/@types/cordova/index.d.ts中:

interface CordovaPlugins {
    notification: any;
...
}
© www.soinside.com 2019 - 2024. All rights reserved.