Ionic Android上的推送通知中没有声音(离子电容器)

6jjcrrmo  于 2022-12-08  发布在  Ionic
关注(0)|答案(1)|浏览(215)

我有一个问题,当我实现了一个插件PushNotification在电容器,问题是,当电话收到推通知不发出任何声音.这是我的代码.

PushNotifications.addListener('pushNotificationReceived',
  (notification: PushNotification) => {
    console.log('Push received: ',JSON.stringify(notification));

  }

这是capacitor.config.json中的设置

"PushNotifications": {
  "presentationOptions": ["badge", "sound", "alert"]
}

谢谢你的帮助。

yptwkmov

yptwkmov1#

显示已创建的通知通道详细信息。
那就不要在Redmi或mi手机上测试。

addListenersForNotifications = async () => {
   await PushNotifications.addListener('registration', 'registration Name');
await PushNotifications.addListener('registrationError', 'error');
await PushNotifications.createChannel({
  id: 'fcm_default_channel',
  name: 'app name',
  description: 'Show the notification if the app is open on your device',
  importance: 5,
  visibility: 1,
  lights: true,
  vibration: true,
});
await PushNotifications.addListener('pushNotificationReceived', this.pushNotificationReceived);
await PushNotifications.addListener('pushNotificationActionPerformed', this.pushNotificationActionPerformed);

};

相关问题