如何在iPhone中删除本地通知 [英] How to delete a local notification in iPhone

查看:119
本文介绍了如何在iPhone中删除本地通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个设置本地通知的应用程序。

I am making an application that sets a local notification.

谢天谢地,我能够设置本地通知,但我不知道如何删除通知由我的应用程序设置。

Thankfully I was able to set the local notification but I don't know how to delete the notification which is set by my application.

XCode使用 removeAllNotifications 提供删除功能,但您无法删除应用程序设置的特定通知。

The XCode does provide functionality of delete with removeAllNotifications but you cannot remove specific notifications set by the application.

非常感谢。

推荐答案

你问过这个问题两次,所以我正在回答这两个问题,希望能找到你:

You asked this question twice, so I'm answering on both questions in the hopes of it reaching you:

使用以下代码取消所有本地通知:

Cancel all local notifications with this code:

[[UIApplication sharedApplication] cancelAllLocalNotifications];






使用以下代码行取消一个本地通知:


Cancel one local notification with this line of code:

[[UIApplication sharedApplication] cancelLocalNotification:theNotification];

其中 theNotification UILocalNotification 对象,所以为了取消特定通知你需要保持它的 UILocalNotification

where theNotification is a UILocalNotification object, so in order to cancel a specific notification you need to hold on to it's UILocalNotification.

您可以在 apple的文档

这篇关于如何在iPhone中删除本地通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆