0

Hello Guys I am working on my flutter project Where I am using awesome notification. I want to do two things.

  1. The device notification sound will be the sound source.

  2. The custom sound provided by me will be the sound source.

I don't know How to do point 1. However for point 2 I added notification.mp3 file in my asset folder and give soundSource: 'assets/notification.mp3'

My Notification initialize Code:

AwesomeNotifications().initialize(
      null,
      [
        NotificationChannel(
          channelKey: 'key1',
          channelName: 'Recipedia',
          channelDescription: 'Testing Notification',
          defaultColor: const Color(0XFFff735c),
          ledColor: const Color(0XFFff735c),
          soundSource: 'assets/notification.mp3',
          enableLights: true,
          enableVibration: true,
          playSound: true,
        )
      ],
  );

My createNotification code:

void OTPNotification() async {
  AwesomeNotifications().createNotification(
      content: NotificationContent(
        id: 1,
        channelKey: 'key1',
        title: 'Recipedia',
        body: 'We have sent you a OTP code. Please check your email.',
        bigPicture: 'assets/OTP1.png',
        notificationLayout: NotificationLayout.BigPicture,
      )
  );
}
Mr Fin
  • 85
  • 8

0 Answers0