Detailed Member Reference

Namespace: Canley.Utility.Notifications
Class: CanleyNotificationService

UpdateCalendar

public static void UpdateCalendar(string id, string title, string body, int? year, int? month, int? day, int? hour, int? minute, int? second, bool repeats = false)
  • Description: Performs an “Upsert” on a calendar-based notification. If the specified ID already exists, it overwrites the existing schedule; otherwise, it registers a new calendar alert.

NOTE

Like ScheduleCalendar, UpdateCalendar honors the global CanleyNotificationService.UseUtc setting when calculating the UTC, (UseUtc = true), or local time, (UseUtc = false),trigger for the updated payload.

  • Parameters:

    • id (string): The unique GUID representing the notification ID to update.
    • title (string): The header text of the notification.
    • body (string): The primary message content.
    • 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): Whether the notification should trigger periodically (default: false).
  • Workflow:

    1. Upsert Check: Scans the active registry for the provided GUID, clearing out any stale configuration before applying the new trigger parameters.
    2. Global Timing Evaluation: Evaluates the incoming date components against the active global CanleyNotificationService.UseUtc property.
  • Return Type: void

  • Access: Public Static

  • Example:

using Canley.Utility.Notifications;
using UnityEngine;
 
public class NotificationManager : MonoBehaviour 
{
    private string _existingId = "your-guid-here";
 
    public void ShiftEventTime() 
    {
        // Update an existing calendar event to 5:00 PM (17:00) while leaving date filters null
        CanleyNotificationService.UpdateCalendar(
            _existingId,
            "Event Update",
            "The event start time has shifted.",
            null, // year
            null, // month
            null, // day
            17,   // hour
            0,    // minute
            0,    // second
            false // repeats
        );
 
        Debug.Log($"Successfully updated calendar notification: {_existingId}");
    }
 
    public void QuickShiftHour()
    {
        // Simple case: using named arguments to target only the hour without typing out blocks of nulls
        CanleyNotificationService.UpdateCalendar(
            id: _existingId,
            title: "Quick Shift",
            body: "The hour has changed.",
            hour: 17
        );
    }
}

TIP

This method handles both creation and modification cleanly under the hood. If you aren’t sure whether an alert ID is currently active in the queue, UpdateCalendar safely secures the slot without throwing duplicate registration errors.