react-native - 反应原生 Firebase 消息通知声音在后台没有变化
问题描述
我在我的应用程序中使用@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',
},
});
});
当应用程序在屏幕上打开时,上面的代码可以正常工作,因此我的自定义通知声音可以完美运行。
但是当应用程序在后台运行时,通知声音是默认的(系统默认)
那么我如何在所有情况下设置自定义通知声音。
解决方案
与频道相关的声音,因此请删除您的频道(自定义声音)并重新创建它。创建频道后,您将无法编辑 android 频道,因此如果您要编辑频道,则需要删除并重新创建它。
推荐阅读
- php - 我无法从 SQL 查询中读取数据?
- bash - 如何在 shellscript 的条件下测试动态子字符串变量?
- java - 创建排除引号内容的空格分隔列表
- java - 如何根据java 8中的某些条件迭代和过滤列表?
- c - 在变量初始化上强制转换指向 Matrix 的指针是引用或副本
- java - 自定义对象如何存储在 HashMap 中
- javascript - 带有 boostrap-vue b-table 的 V 模型
- ios - MPMediaPickerController 从不显示在 iOS 13 上,没有打印错误
- c - 运行 Windows SendInput API 时显示器闪烁
- arrays - 计算文本评论中大写单词的数量