android - 通知声音在本机 Firebase v6 中不起作用?
问题描述
我正在向收到通知的用户发送通知,但没有任何声音“默认设备声音”
我添加了一个sound: 'default'
通知有效负载,但仍然无法正常工作!
这是我的功能
// Send notification for user when his order is accepted "status : pendding"
exports.acceptOrder = functions.database
.ref('/Providers/ProvidersOrders/InProgress/{providerUid}/{orderId}')
.onCreate(async (snapshot, context) => {
console.log('snapshot', snapshot.val());
const {userUID} = snapshot.val();
const userRef = await admin
.database()
.ref(`/users/${userUID}`)
.once('value');
const {userToken, username} = userRef.val(); // FCM user app token
try {
const options = {
priority: 'high',
contentAvailable: true,
};
const payload = {
notification: {
title: 'Accepted order',
body: `Hey! ${username}, your order has accepted we will contact with you as soon as possible.`,
timestamp: Date.now().toString(),
isRead: 'false',
sound: 'default',
},
};
let {sound, ...notification} = payload.notification;
let uid = userUID;
await admin
.messaging()
.sendToDevice(userToken, payload, options)
.then(() => {
return admin
.database()
.ref(`Notifications/${uid}`)
.push({...notification});
});
console.log('message sent');
} catch (error) {
console.log('Error sending message:', error);
}
return null;
});
那么这里有什么问题呢?
解决方案
推荐阅读
- java - 了解 SpringBatch /Spring boot 应用程序中的 TaskExecutor
- angular - Angular 11:大型应用程序的文件夹或目录结构
- google-cloud-platform - gzip/非 gzip 本地/云位置之间的 gsutil rsync
- c# - 如何获取数据库值(Lambda 表达式)
- awk - awk:对最后一个单词的文本块进行分组在两个文本文件中都很常见
- c++ - 使用 QNetworkAccessManager 解析 youtube
- html - 表单未使用 Laravel 集合提交
- r - 在R中切换矩阵的列顺序
- python - 如何遍历可见的表单字段但在 Django 中遇到某个字段时执行某些操作?
- java - Android studio自动horizontalscrollview无限滚动直到结束然后重复