从点击通知中心中删除的通知 [英] Removing a notification from notification center on click

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

问题描述

是否有可能从通知中心中删除推送通知当一个人点击,应用程序启动?

大多数应用程序似乎留在原地的通知。我读了另一个问题,这:

  [UIApplication的sharedApplication] setApplicationIconBadgeNumber:0];

但是可能工作不为我工作。

Facebook应用程序肯定似乎删除推送通知,一旦点击。


解决方案

  INT badgeCount = [UIApplication的sharedApplication] .applicationIconBadgeNumber;
[UIApplication的sharedApplication] setApplicationIconBadgeNumber:0];
[UIApplication的sharedApplication] cancelAllLocalNotifications]
[UIApplication的sharedApplication] setApplicationIconBadgeNumber:badgeCount];

如果您添加到两个

   - (无效)applicationWillEnterForeground:(UIApplication的*)的应用

   - (BOOL)应用:(*的UIApplication)的应用didFinishLaunchingWithOptions(*的NSDictionary)launchOptions

您将保留徽章计数,并清除推送通知被点击的通知中心的时候。

Is it possible to remove the push notification from the notification center when one is clicked and the app launches?

Most apps seem to leave the notification in place. I read on another question that this:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; 

may work however it doesn't work for me.

The Facebook app definitely seems to remove the push notifications once clicked on.

解决方案

int badgeCount = [UIApplication sharedApplication].applicationIconBadgeNumber;
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:badgeCount];

If you add this to both

- (void)applicationWillEnterForeground:(UIApplication *)application

And

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions (NSDictionary *)launchOptions

You will retain the badge count, and clear the push notification when it is clicked in the notification center.

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

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