Detailed Member Reference

Namespace: Canley.Utility.Notifications
Class: CanleyNotificationService

UpdateTimed

public static void UpdateTimed(string id, string title, string body, int seconds, bool repeats = false)
  • Description: Performs an “Upsert” operation on a timed notification. If the specified ID already exists, it overwrites the existing alert; otherwise, it creates a brand new one.

  • 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.
    • seconds (int): The duration in seconds until the alert triggers.
    • repeats (bool, optional): Whether the notification should trigger periodically (default: false).
  • Workflow:

    1. Upsert Check: Evaluates whether the target GUID currently exists within the native iOS notification queue.
    2. Purge & Replace: Automatically clears out any stale alert tied to that ID before registering the updated payload to prevent duplicate notifications.
  • 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 RefreshTimedAlert() 
    {
        // Update an existing notification ID to fire in 2 hours instead
        CanleyNotificationService.UpdateTimed(
            _existingId,
            "Still playing!",
            "We've added a bonus to your save file.",
            CanleyNotificationService.ToSeconds(hours: 2),
            false
        );
 
        Debug.Log($"Successfully upserted timed notification: {_existingId}");
    }
}

TIP

The upsert pattern means you don’t need to manually check if a notification exists or call RemoveNotification first when modifying a scheduled timer. Just pass the known ID straight into UpdateTimed.