问题描述
我正在尝试在 iOS 上测试本地通知,但应用在调用 UNUserNotificationCenter.Current.AddNotificationRequest 后崩溃
我按照此处的指南创建了 iOS 通知管理器:https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/local-notifications
var content = new UNMutableNotificationContent()
{
Title = title,Subtitle = "",Body = message,Badge = 1
};
UNNotificationTrigger trigger;
if (notifyTime != null)
{
trigger = UNCalendarNotificationTrigger.CreateTrigger(GetNSDateComponents(notifyTime.Value),false);
}
else
{
trigger = UNTimeIntervalNotificationTrigger.CreateTrigger(0.25,false);
}
var request = UNNotificationRequest.FromIdentifier(messageId.ToString(),content,trigger);
UNUserNotificationCenter.Current.AddNotificationRequest(request,(err) =>
{
if (err != null)
{
throw new Exception($"Failed to schedule notification: {err}");
}
});
我放置了一个断点来检查“err”是否不为空,但它始终为空。
可能是什么问题?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)