1

I want to add resource file for custom sound, i'm using awesome_notification package

this is my code

import 'package:awesome_notifications/awesome_notifications.dart';
import 'package:flutter/material.dart';

import 'notifcation_model.dart';

class NotificationHelper {
  static final List<NotificationItem> notifications = [
    NotificationItem(channelKey: "azan1", path: "resource://raw/azan1"),
    NotificationItem(channelKey: "azan2", path: "resource://raw/azan2")
  ];

  static Future<void> initNotification() async {
    AwesomeNotifications().initialize(
      "resource://drawable/logo",
      List.generate(
          notifications.length,
          (index) => NotificationChannel(
              channelKey: notifications[index].channelKey,
              channelName: 'Alarms Channel',
              channelDescription: 'Channel with alarm ringtone',
              defaultColor: const Color(0xFF9D50DD),
              importance: NotificationImportance.Max,
              ledColor: Colors.white,
              channelShowBadge: true,
              locked: true,
              defaultRingtoneType: DefaultRingtoneType.Alarm,
              soundSource: notifications[index].path)),
      debug: true,
    );
  }

  Future<void> showCustomNotification(
      int notificationId, String title, String body, DateTime date,
      {String? channelKey, required String localTimeZone}) async {
    await AwesomeNotifications().createNotification(
        content: NotificationContent(
          id: notificationId,
          channelKey: channelKey ??
              notifications[0].channelKey, // Replace with your channel key
          title: title,
          body: body,
          category: NotificationCategory.Alarm,
          wakeUpScreen: true,
        ),
        schedule: NotificationCalendar(
          hour: date.hour,
          minute: date.minute,
          second: date.second,
          timeZone: localTimeZone,
          repeats: true,
        ),
        actionButtons: [
          NotificationActionButton(
              key: 'DISMISS',
              label: 'Dismiss',
              autoDismissible: true,
              buttonType: ActionButtonType.DisabledAction),
        ]);
  }
}

It's working in android because i add sound in android/app/main/res/raw but how can i add this sounds in IOS Directory?

I tried to add it, but i don't know the correct path for adding it in IOS

0 Answers0