How do you ensure that your app's notifications are cleared from Notification Center after a user views the related item?
-
For example, when displays a notification for a new picture posted by a friend and I go to view the picture, the notification isn't cleared from Notification Center. There is actually no way to clear these notifications other than to tap "x" and then "clear" in Notification Center. Tapping on the notification, viewing the related items in app and/or simply opening the app do not clear the notifications. What code/triggers does Path need to include to ensure that the notification will be cleared from Notification Center? There is definitely something that can be done to clear the notifications after viewing because 's notifications disappear after viewing the item, while and 's notifications are never cleared until you tap the "x" and then "clear" to explicitly clear them. Why/how do some apps clear these notifications after viewing while others don't?
-
Answer:
There's no explicit "consume notification" call that relates to the notification center, nor any specific documentation I can find regarding what causes notifications to disappear from the notification center. However, as you note, it's obviously possible, and is handled differently depending on the app. From what I can gather, this is an all or nothing thing-- as in, you can clear out the notification center for your app but not selectively clear individual notifications. The key steps seem to be: Set the app's icon badge number to 0. (You can later reset it to its previous value if it makes sense-- the important thing seems to be to make it zero, even temporarily). call cancelAllLocalNotifications (even if you're only using push notifications). Make sure these steps happen both when the app finishes launching and when it becomes the foreground app. This is somewhat guesswork since I haven't tried it and don't have time to put together a test project to verify it. If I wanted to clear notification center messages for an app though, this is where I'd start. I wonder if would be willing to comment on what the Quora app does here, since it's in the camp of clearing messages from the notification center.
Tom Harrington at Quora Visit the source
Other answers
There is indeed an official mention to this in Apple documentation (iOS 5 release notes): http://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-5_0/_index.html Springboard Push and local notifications for apps appear in the new Notification Center in iOS 5. Notification Center displays notifications that are considered "unread.â To accommodate push and local notifications that have no unread status, set your applicationâs badge count to 0 to clear that appâs notifications from Notification Center.
Ary Tebeka
According to a response on [1], this seems to do the trick: [[UIApplication sharedApplication] setApplicationIconBadgeNumber:1]; [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; That is, once your app handles the notification, toggle the Badge Number to 1, then 0, and away they go! Of course, now I'm wondering if this is an unintentional side-effect we'd be taking advantage of? Hehehe ... :) [1] http://stackoverflow.com/a/7821985/126660
Joe D'Andrea
Related Q & A:
- How To Use the Graph API to Upload Photos to a user’s profile?Best solution by Stack Overflow
- How to follow a user using tweetsharp?Best solution by Stack Overflow
- How to properly reference a user control and dynamically add it to page?Best solution by Stack Overflow
- How to check on all the permissions granted to a user and apply the same permissions to another user?Best solution by Stack Overflow
- How do I permanently block a user forever? I mean, find or enter the username, when the user isnt on my list?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.