具有不同声音的重复通知 - 远程推送通知

Duplicate notifications with different sounds - push notification remote

我正在尝试在推送通知中添加自定义声音。我已经在客户端(flutter)的后台处理程序中添加了 showNotification,但是现在当应用程序在后台或终止时,我收到重复的通知,一个是默认声音,另一个是我的自定义声音。谁能告诉我如何停止显示默认后台通知?

您收到重复的通知是因为

  1. 您发送的是 notification message,FCM SDK 会自动显示它,
  2. 您正在自己实现自定义通知显示。

解决方案是发送 data message 而不是 notification message

With FCM, you can send two types of messages to clients:

  • Notification messages, sometimes thought of as "display messages." These are handled by the FCM SDK automatically.
  • Data messages, which are handled by the client app.

Source