CanleyNotificationService
Namespace: Canley.Utility.Notifications
Type: Static Class
Overview
The CanleyNotificationService class is the central engine for the notifications suite. It bridges clean C# method calls to platform-native local notifications on iOS. Because it is a static class, it requires no scene setup and provides a single, high-performance entry point for managing local notification queues.
It is designed to be zero-dependency and editor-safe, allowing you to schedule, update, and inspect alerts seamlessly.
Setting Reference
Global configuration properties for the notification engine.
| Class | Member (Syntax) | Description |
|---|---|---|
| CanleyNotificationService | UseUtc | Toggles whether calendar-based triggers evaluate against UTC or local device time. |
Method Reference
Detailed documentation for core service methods.
| Class | Method (Syntax) | Description |
|---|---|---|
| CanleyNotificationService | Initialise() | Requests alert, sound, and badge permissions from the OS. |
| CanleyNotificationService | ScheduleTimed(string, string, int, bool) | Schedules a relative time-delay notification and returns its unique GUID. |
| CanleyNotificationService | ScheduleCalendar(…) | Schedules an alert for a precise calendar date and time, returning its GUID. |
| CanleyNotificationService | GetNotification(string) | Retrieves a specific CanleyNotificationRecord struct by ID, or null if not found. |
| CanleyNotificationService | GetAllNotifications() | Returns a list of all currently scheduled notification records. |
| CanleyNotificationService | UpdateTimed(…) | Performs an upsert operation on an existing timed notification. |
| CanleyNotificationService | UpdateCalendar(…) | Performs an upsert operation on an existing calendar-based notification. |
| CanleyNotificationService | RemoveNotification(string) | Immediately cancels and removes a specific notification by its unique ID. |
| CanleyNotificationService | ClearAll() | Performs a hard purge of the notification center, clearing all scheduled and delivered alerts. |
| CanleyNotificationService | ToSeconds(int, int, int, int) | Helper utility to calculate total seconds from days, hours, minutes, and seconds. |
Key Features
- Zero-Dependency Core: Pure C# logic that interacts natively with the iOS Notification Center without bloating your project.
- Editor-Safe Simulation: Provides non-intrusive console-based simulation on PC and Mac so you can debug your logic without pushing builds to physical hardware.
- CRUD-Ready Architecture: Tracks notifications as records via unique IDs, letting you update, remove, or query active alerts at any time.
- “Shadow” Update Logic: Upsert methods automatically check and purge stale alerts before registering new ones to prevent common duplicate notification bugs.
TIP
Always call
CanleyNotificationService.Initialise()during your application’s initial boot sequence to ensure user permissions are requested cleanly before scheduling any delayed or calendar notifications.