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,UpdateCalendarhonors the globalCanleyNotificationService.UseUtcsetting 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, ornullto ignore.month(int?, optional): Specific month constraint, ornullto ignore.day(int?, optional): Specific day constraint, ornullto ignore.hour(int?, optional): Specific hour constraint (24-hour format), ornullto ignore.minute(int?, optional): Specific minute constraint, ornullto ignore.second(int?, optional): Specific second constraint, ornullto ignore.repeats(bool, optional): Whether the notification should trigger periodically (default:false).
-
Workflow:
- Upsert Check: Scans the active registry for the provided GUID, clearing out any stale configuration before applying the new trigger parameters.
- Global Timing Evaluation: Evaluates the incoming date components against the active global
CanleyNotificationService.UseUtcproperty.
-
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,
UpdateCalendarsafely secures the slot without throwing duplicate registration errors.