【问题标题】:Ionic 4 local notification sound not working in Oreo+Ionic 4 本地通知声音在 Oreo+ 中不起作用
【发布时间】:2019-10-21 13:54:10
【问题描述】:

我正在构建一个 Ionic 4 应用程序,本地通知 sound 在 Nougat 中工作,但在 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
    });

但是就像我在 ionic 中没有可用的“通道”字段一样,我在这里设置了一个问题,但很接近。 https://github.com/ionic-team/ionic/issues/19696

你有什么建议我怎样才能让它工作吗?

【问题讨论】:

    标签: ionic-framework audio android-8.0-oreo localnotification


    【解决方案1】:

    我正在使用这个 "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;
    ...
    }
    

    【讨论】:

      猜你喜欢
      • 2023-03-13
      • 1970-01-01
      • 2018-11-07
      • 2021-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多