1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] iOS Notification Issue with Custom Alarm Using ‘Awesome Notification’ in Flutter:...

Discussão em 'Mobile' iniciado por Stack, Novembro 6, 2024 às 11:22.

  1. Stack

    Stack Membro Participativo

    I want the notification to repeat. It works as expected in the foreground, but in the background, the notification only appears once and disappears. Since it’s an alarm app, I need the notification to keep repeating until the user clicks on it, even in the background. Below is the code I have written.

    static void initializeNotificationListeners() {
    print('Initializing notification listeners');

    AwesomeNotifications().setListeners(
    onActionReceivedMethod: onActionReceivedMethod,
    onNotificationDisplayedMethod: onNotificationDisplayedMethod,
    );
    print('Notification listeners set');
    }


    static Future<void> onNotificationDisplayedMethod(ReceivedNotification receivedNotification) async {

    _notificationTimer?.cancel();

    _notificationTimer = Timer.periodic(Duration(seconds: 7), (timer) async {
    int? subId = int.tryParse(receivedNotification.payload?['subId'] ?? '');

    await AwesomeNotifications().createNotification(
    content: NotificationContent(
    criticalAlert: true,
    displayOnBackground: true,
    displayOnForeground: true,
    fullScreenIntent: true,


    id: subId!,
    channelKey: "alarm_Category",
    title: 'Alarm Reminder',
    body: 'Your alarm is still active!',
    autoDismissible: false,
    payload: receivedNotification.payload,

    ),
    );
    });
    }

    Continue reading...

Compartilhe esta Página