Skip to content

4. Repeat Notification

Elvin Thudugala edited this page Mar 29, 2026 · 5 revisions

Repeating Notifications Guide

Overview

Repeating notifications are useful for recurring reminders, periodic updates, or any scenario where you need to notify users regularly. This guide covers how to implement different types of recurring notifications.

Prerequisites

  • Notifications must be scheduled (using NotifyTime)
  • NotifyTime is a DateTimeOffset? — use DateTimeOffset.Now (not DateTime.Now) so timezone information is preserved correctly
  • Proper permissions must be granted
  • Consider platform-specific limitations

Repeat Types

The plugin supports four types of recurring notifications:

1. Daily Repeat

Notification repeats every day at the same time.

using Plugin.LocalNotification;
using Plugin.LocalNotification.Core.Models;
var dailyReminder = new NotificationRequest
{
    NotificationId = 100,
    Title = "Daily Reminder",
    Description = "This notification appears every day",
    Schedule = 
    {
        NotifyTime = DateTimeOffset.Now.Date.AddHours(9), // 9:00 AM
        RepeatType = NotificationRepeat.Daily
    }
};
await LocalNotificationCenter.Current.Show(dailyReminder);

2. Weekly Repeat

Notification repeats on the same day each week at the same time.

var weeklyReminder = new NotificationRequest
{
    NotificationId = 101,
    Title = "Weekly Meeting",
    Description = "Team sync every Monday",
    Schedule = 
    {
        NotifyTime = DateTimeOffset.Now.Date.AddDays(
            ((int)DayOfWeek.Monday - (int)DateTimeOffset.Now.DayOfWeek + 7) % 7
        ).AddHours(10), // Next Monday at 10:00 AM
        RepeatType = NotificationRepeat.Weekly
    }
};
await LocalNotificationCenter.Current.Show(weeklyReminder);

3. Time Interval

Notification repeats after a specified time interval.

var intervalReminder = new NotificationRequest
{
    NotificationId = 102,
    Title = "Periodic Update",
    Description = "Checking for updates",
    Schedule = 
    {
        NotifyTime = DateTimeOffset.Now.AddMinutes(30), // First notification after 30 minutes
        RepeatType = NotificationRepeat.TimeInterval,
        NotifyRepeatInterval = TimeSpan.FromHours(2) // Then every 2 hours
    }
};
await LocalNotificationCenter.Current.Show(intervalReminder);

4. Monthly Repeat

Notification repeats on the same day of each month at the same time.

var monthlyReminder = new NotificationRequest
{
    NotificationId = 103,
    Title = "Monthly Report",
    Description = "Time to submit your monthly report",
    Schedule =
    {
        NotifyTime = DateTimeOffset.Now.AddMonths(1), // First fire next month, same day
        RepeatType = NotificationRepeat.Monthly
    }
};
await LocalNotificationCenter.Current.Show(monthlyReminder);

Note: When the schedule day does not exist in the next month (e.g., 31st of a month without 31 days), DateTimeOffset.AddMonths clamps to the last day of that month — consistent with standard .NET calendar arithmetic.

Platform-Specific Considerations

iOS Limitations

  • TimeInterval notifications cannot have both delay and repeat
  • Use Daily or Weekly repeat for more precise timing
  • Background refresh may affect timing

Android Considerations

  • Battery optimization may affect timing
  • Doze mode can delay notifications
  • Consider using Foreground Service for critical timing

Managing Repeating Notifications

Cancel a Repeating Notification

await LocalNotificationCenter.Current.Cancel(notificationId);

Update a Repeating Notification

// Cancel existing notification
await LocalNotificationCenter.Current.Cancel(notificationId);

// Create new notification with updated parameters
var updatedNotification = new NotificationRequest
{
    NotificationId = notificationId,
    Title = "Updated Reminder",
    Description = "Modified repeating notification",
    Schedule = 
    {
        NotifyTime = newDateTime,
        RepeatType = NotificationRepeat.Daily
    }
};
await LocalNotificationCenter.Current.Show(updatedNotification);

Check Pending Notifications

var pendingNotifications = await LocalNotificationCenter.Current.GetPendingNotificationList();
foreach (var notification in pendingNotifications)
{
    if (notification.Schedule.RepeatType != NotificationRepeat.No)
    {
        // Handle repeating notification
    }
}

Best Practices

  1. Unique IDs

    • Use different ID ranges for different types of notifications
    • Keep track of notification IDs for management
  2. Timing Considerations

    // Bad: Might miss notifications if app is closed
    NotifyTime = DateTimeOffset.Now.AddMinutes(1)
    
    // Good: Use future time that won't be missed
    NotifyTime = DateTimeOffset.Now.AddMinutes(5)
  3. Error Handling

    try
    {
        await LocalNotificationCenter.Current.Show(notification);
    }
    catch (Exception ex)
    {
        // Log error and implement retry logic if needed
        Debug.WriteLine($"Failed to schedule notification: {ex.Message}");
    }
  4. Resource Management

    • Limit the number of concurrent repeating notifications
    • Clean up unused notifications
    • Consider battery and system resource impact

Common Issues and Solutions

1. Notifications Not Repeating

Check:

  • Correct RepeatType is set
  • NotifyTime is in the future
  • Platform-specific restrictions
  • Battery optimization settings

2. Irregular Timing

Solutions:

  • Use longer intervals (15+ minutes)
  • Implement retry logic
  • Consider using push notifications
  • Check system clock synchronization

3. Performance Impact

Recommendations:

  • Use appropriate intervals (not too frequent)
  • Clean up unnecessary notifications
  • Monitor battery usage
  • Implement user controls for frequency

Examples

Work Week Reminder

var workdayReminder = new NotificationRequest
{
    NotificationId = 103,
    Title = "Daily Standup",
    Description = "Time for team standup",
    Schedule = 
    {
        NotifyTime = GetNextWorkday().AddHours(9).AddMinutes(30), // 9:30 AM
        RepeatType = NotificationRepeat.Daily
    }
};

private DateTime GetNextWorkday()
{
    var date = DateTime.Today;
    while (date.DayOfWeek == DayOfWeek.Saturday || 
           date.DayOfWeek == DayOfWeek.Sunday)
    {
        date = date.AddDays(1);
    }
    return date;
}

Health App Style Reminder

var healthReminder = new NotificationRequest
{
    NotificationId = 104,
    Title = "Activity Check",
    Description = "Time to move!",
    Schedule = 
    {
        NotifyTime = DateTime.Now.AddHours(1),
        RepeatType = NotificationRepeat.TimeInterval,
        NotifyRepeatInterval = TimeSpan.FromHours(2)
    },
    Android = 
    {
        Priority = AndroidPriority.High,
        ChannelId = "health_reminders"
    }
};

Clone this wiki locally