【发布时间】:2013-06-02 16:37:01
【问题描述】:
这可能是一个重复的链接。
Remove single remote notification from Notification Center
根据这篇文章,我们无法从通知中心(NC)删除单个通知。 对于取消通知,我们有以下方法。
1).cancelAllLocalNotifications :它删除所有通知。 2).cancelLocalNotification : 它需要通知作为输入。
我尝试了这两种方法,使用第一种方法会从 NC 中删除所有通知,而第二种方法似乎不起作用。 这是我在 didRecivedRemoteNoitification 方法上应用的第二个 sn-p。
UIApplication *app = [UIApplication sharedApplication];
NSArray *eventArray = [app scheduledLocalNotifications];
for (int i=0; i<[eventArray count]; i++)
{
UILocalNotification* oneEvent = [eventArray objectAtIndex:i];
NSDictionary *userInfoCurrent = oneEvent.userInfo;
NSLog(@"userInfoCurrent : %@", userInfoCurrent);
int notiid=[[userInfoCurrent valueForKey:@"notificationID"] intValue];
if (notiid ==deletenotiid)
{
//Cancelling local notification
[app cancelLocalNotification:oneEvent];
break;
}
}
所以我的问题是我看到几个应用程序从 NC 中删除了一个被点击的通知,例如 skype
有什么我想申请的吗?
感谢您宝贵的时间。
【问题讨论】:
-
您只能取消本地通知,不能取消远程通知(因为本地通知已安排,因此您可以在它们启动之前取消它们)。
-
其实我正在寻找远程推送通知;在给定的帖子中,提到了一种删除所有通知的解决方案,但是我的要求是只删除被点击的一个。
标签: ios notifications apple-push-notifications