react-native - react native firebase 消息通知声音在后台不会改变

标签 react-native push-notification android-notifications firebase-notifications

我在我的应用程序中使用@react-native-firebase/messaging 进行推送通知。 对于自定义通知声音,我使用@notifee/react-native this。

我当前的通知代码是:

import messaging from '@react-native-firebase/messaging';
import notifee from '@notifee/react-native';

await notifee.createChannel({
      id: 'custom-sound',
      name: 'System Sound',
      sound: 'notification.mp3',
});

messaging().onMessage((remoteMessage) => {
      notifee.displayNotification({
        title: remoteMessage.notification.title,
        body: remoteMessage.notification.body,
        android: {
          channelId: 'custom-sound',
        },
      });
});


当应用程序在屏幕上打开时,上面的代码可以正常工作,因此我的自定义通知声音可以完美运行。

但是当应用程序在后台运行时,通知声音是默认的(系统默认)

那么我如何在所有情况下设置自定义通知声音。

This my notification payload

最佳答案

与 channel 相关的声音,因此请删除您的 channel (自定义声音)并重新创建。创建 channel 后,您将无法编辑 Android channel ,因此如果您要编辑 channel ,则需要删除并重新创建它。

关于react-native - react native firebase 消息通知声音在后台不会改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66636661/

相关文章:

javascript - 如何向 react-native snap carousel 提供 API 数据

reactjs - 是否可以使 VictoryPie 切片相互重叠?

ios - Swift - 如何在收到推送通知时打开特定的 View Controller ?

iOS:推送通知、UIApplicationStateInactive 和快速应用切换

android - 在用户不点击通知的情况下处理数据负载?

typescript - react native 部分列表 : What are the correct TypeScript types

node.js - 如何立即加载更改 - React Native

ios - 为什么deviceToken是以NSData类型传递的,在application :didRegisterForRemoteNotificationsWithDeviceToken?

android - 在通知中使用 Picasso 的最简单方法(图标)

java - 如何为具有特定日期的用户配置通知,然后将其存储在房间数据库中