Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

ios5 - Can I programmatically clear my app's notifications from the iOS 5 Notification Center?

I would like to remove old notifications that my app has made from the iOS 5 Notification Center. Can I do this? If so, how?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To remove notifications from the Notification Center simply set your icon badge number to zero.

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];

This only works if the number changes, so if your app doesn't use the badge number you have to first set, then reset it.

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...