码迷,mamicode.com
首页 > 移动开发 > 详细

iOS application: how to clear notifications?

时间:2016-05-18 12:33:27      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:

http://stackoverflow.com/questions/8682051/ios-application-how-to-clear-notifications

 

Just to expand on pcperini‘s answer. As he mentions you will need to add the following code to yourapplication:didFinishLaunchingWithOptions: method;

[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];

You Also need to increment then decrement the badge in your application:didReceiveRemoteNotification: method if you are trying to clear the message from the message centre so that when a user enters you app from pressing a notification the message centre will also clear, ie;

[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 1];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];

iOS application: how to clear notifications?

标签:

原文地址:http://www.cnblogs.com/willbin/p/5504546.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!