Monotouch - 取消本地通知

时间:2011-08-10 00:02:51

标签: c# ios xamarin.ios uilocalnotification uiapplication

是否有人使用此功能取消之前安排的本地通知?我在文档中看到它,但无法将其连接到代码中。

UIApplication.SharedApplication.ScheduledLocalNotifications schedNoteList = new 
                 UIApplication.SharedApplication.ScheduledLocalNotifications();
        foreach(UILocalNotification sNote in schedNoteList)
        {
            if(sNote.FireDate == oldDate)
            {
                //Cancel the Notification
                UIApplication.CancelLocalNotification(sNote);
            }
        }

谢谢, 瑞克

1 个答案:

答案 0 :(得分:2)

此代码将编译:

    foreach(UILocalNotification sNote in UIApplication.SharedApplication.ScheduledLocalNotifications)
    {
        if(sNote.FireDate == DateTime.Now)
        {
            //Cancel the Notification'
            UIApplication.SharedApplication.CancelLocalNotification (sNote);
        }
    }

但我不能说它是否会做你想做的事情(因为我主要是使用MonoDevelop代码完成重新编写你的代码)。