Monotouch-取消本地通知

发布于 2024-11-28 22:14:14 字数 502 浏览 4 评论 0原文

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

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

谢谢, 瑞克

Anyone used this to cancel a previously scheduled Local Notification? I see it in the documentation but can't get it wired up in code.

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

Thanks,
Rick

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄人书 2024-12-05 22:14:14

这段代码将编译:

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

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

This code will compile:

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

but I cannot say if it will do what you want it to do (since I mostly reworked your code using MonoDevelop code completion).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文