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
nullis 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, 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): A flag determining whether the notification should trigger periodically (default:false).
NOTE
ScheduleCalendarrelies on the globalCanleyNotificationService.UseUtcproperty to determine whether your calendar constraints are evaluated against absolute global time or the user’s local device wall-clock time.
-
Workflow:
- Parameter Filtering: Evaluates all nullable date/time components, leaving unspecified fields open for recurring or flexible triggers.
- Timezone Evaluation: Evaluates the scheduled time against the global
UseUtcproperty configuration. - 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
nullwhile specifying your target hours and minutes withrepeatsset totrue.