Detailed Member Reference

Namespace: Canley.Utility.Notifications
Class: CanleyNotificationService

ScheduleCalendar

public static string ScheduleCalendar(string title, string body, int? year, int? month, int? day, int? hour, int? minute, int? second, bool repeats = false)
  • Description: Schedules an alert for a precise calendar date and time. Any parameter set to null is ignored by the OS trigger.
  • Parameters:
    • title (string): The header text of the notification banner.
    • body (string): The primary message content shown to the user.
    • year (int?, optional): Specific year constraint, or null to ignore.
    • month (int?, optional): Specific month constraint, or null to ignore.
    • day (int?, optional): Specific day constraint, or null to ignore.
    • hour (int?, optional): Specific hour constraint (24-hour format), or null to ignore.
    • minute (int?, optional): Specific minute constraint, or null to ignore.
    • second (int?, optional): Specific second constraint, or null to ignore.
    • repeats (bool, optional): A flag determining whether the notification should trigger periodically (default: false).

NOTE

ScheduleCalendar relies on the global CanleyNotificationService.UseUtc property to determine whether your calendar constraints are evaluated against absolute global time or the user’s local device wall-clock time.

  • Workflow:

    1. Parameter Filtering: Evaluates all nullable date/time components, leaving unspecified fields open for recurring or flexible triggers.
    2. Timezone Evaluation: Evaluates the scheduled time against the global UseUtc property configuration.
    3. ID Generation: Assigns and returns a unique GUID string handle for future tracking.
  • Return Type: string (Returns the assigned unique GUID string handle).

  • Access: Public Static

  • Example:

using Canley.Utility.Notifications;
using UnityEngine;
 
public class DailyRewardScheduler : MonoBehaviour 
{
    private string _calendarNoteId;
 
    public void ScheduleDailyReminder() 
    {
        // Configure global timing behaviour prior to scheduling
        CanleyNotificationService.UseUtc = false; // Evaluates against local device wall-clock time
 
        // Schedule for 9:30 AM every day (ignoring year, month, and day)
        _calendarNoteId = CanleyNotificationService.ScheduleCalendar(
            "Daily Reward",
            "Claim your free gift!",
            null, // year
            null, // month
            null, // day
            9,    // hour
            30,   // minute
            0,    // second
            true  // repeats
        );
 
        Debug.Log($"Scheduled recurring calendar notification with ID: {_calendarNoteId}");
    }
}

TIP

Setting recurring calendar notifications (such as daily alarms) is as simple as leaving the date parameters as null while specifying your target hours and minutes with repeats set to true.