No custom sound with Android Firebase Notification

后端 未结 6 1575
轮回少年
轮回少年 2021-01-17 10:39

I am using Firebase push notifications in my Android App. I can send correctly notification with custom icon, but I have not managed to play my custom sound. I always get th

6条回答
  •  萌比男神i
    2021-01-17 11:27

    From the documentation, include the sound in notification object under android object. Give name of the sound file in sound value. The sound files must reside in /res/raw/ . Below is a Node.js example:-

      var message = {
      notification: {
        title: 'sample title',
        body: 'Hello, its Tuesday.',
      },
      android: {
        ttl: 3600 * 1000,
        notification: {
          icon: 'my_icon',
          color: '#f45342',
          sound: 'filename.mp3',
        },
      },
      apns: {
        payload: {
          aps: {
            badge: 42,
          },
        },
      },
      topic: 'industry-tech'
    };
    

提交回复
热议问题