using System; using UserNotifications; namespace Other { public class ScheduleLocalNotification { public void SetScheduleLocalNotification() { // 创建通知内容 var content = new UNMutableNotificationContent { Title = "自定义铃声通知", Body = "这是带有自定义铃声的本地通知。", Sound = UNNotificationSound.GetSound("oldphone_mono.wav") // 替换为您的音频文件名 }; // 设置触发时间(例如,5秒后触发) var trigger = UNTimeIntervalNotificationTrigger.CreateTrigger(5, false); // 创建通知请求 var request = UNNotificationRequest.FromIdentifier(Guid.NewGuid().ToString(), content, trigger); // 添加通知请求到通知中心 UNUserNotificationCenter.Current.AddNotificationRequest(request, (error) => { if (error != null) { // 处理错误 Console.WriteLine($"添加通知失败: {error.LocalizedDescription}"); } }); } } }