Firebase推送通知自定义声音不起作用

时间:2020-08-11 05:03:34

标签: javascript android firebase firebase-cloud-messaging firebase-notifications

我创建了一个工具来测试项目的Firebase推送通知,并为通知添加了自定义声音。自定义声音在IOS上正常运行,但在android中,某些设备会播放默认声音,而不是自定义声音。

下面,我分享了我的代码。谁能帮帮我吗?预先感谢。

var registrationToken = 'YOUR_REGISTRATION_TOKEN';

var message = {
  notification: {
    title: 'Title',
    body: 'Body',
  },
  android: {
    priority: 'high',
    notification: {
      sound: 'ringing.mp3',
      defaultVibrateTimings: true,
    },
  },
  apns: {
    payload: { aps: { sound: 'ringing.mp3', badge: 0 } },
  },
  token: registrationToken,
};

admin
  .messaging()
  .send(message)
  .then(response => {
    console.log('Successfully sent message:', response);
  })
  .catch(error => {
    console.log('Error sending message:', error);
  });

0 个答案:

没有答案