1

I want to customize the sound which should be playing, when my notification gets triggered. Unfortunately, not even the default ringtone works. I have an m4a-file in the folder android/app/src/main/res/raw and no Error shows up.

This is my channel initialization:

static Future<void> initializeLocalNotifications() async {
    await AwesomeNotifications().initialize(
        null,
        [
          NotificationChannel(
              channelKey: 'alarms_channel',
              channelName: 'Alarms',
              channelDescription: 'Notification tests as alarms',
              importance: NotificationImportance.Max,
              soundSource: 'resource://raw/res_security_alarm',
              playSound: true,
              //defaultRingtoneType: DefaultRingtoneType.Alarm,
              defaultPrivacy: NotificationPrivacy.Public,
              defaultColor: COLOR_BACKGROUND,
              ledColor: Colors.orange,
              ledOnMs: 1000,
              ledOffMs: 500,
              enableLights: true,
              enableVibration: true,
          )
        ],
        debug: true
    );

    initialAction = await AwesomeNotifications()
        .getInitialNotificationAction(removeFromActionEvents: false);
  }

and this is how I create a notification:

await AwesomeNotifications().createNotification(
      content: NotificationContent(
        id: -1,
        channelKey: 'alarms_channel',
        title: 'This is Notification title',
        body: 'This is Body of Notification',
        ticker: 'this is a ticker',
        wakeUpScreen: true,
        fullScreenIntent: true,
        category: NotificationCategory.Alarm,
        customSound: 'resource://raw/res_security_alarm',
        //customSound: "String",
        criticalAlert: true,
        displayOnForeground: true,
        displayOnBackground: true,
        color: COLOR_LIGHT,
        backgroundColor: COLOR_BACKGROUND,
      ),
      schedule: NotificationInterval(
        interval: 5,
        timeZone: timezone,
        preciseAlarm: true,
        allowWhileIdle: true,
      ),
      actionButtons: [
        NotificationActionButton(
          key: "DISMISS",
          label: "dismiss",
        ),
      ],

I tried switching up the order in the initialization, but nothing works. I also tried the different things in the create method with the parameter customSound .

0 Answers0