10

I notice that for apps like Google Hangout, Facebook etc. when I get a push notification for any event (people writing on my wall, etc.), if I view the event on my desktop, it will clear the push notification (which I have not cleared myself or opened the app for) on my iPhone.

How can I implement the same?

Right now i'm using this app for implementing my push's.

I customized the above, but the implementation is similar. Do I need to send any special data to the phone to clear all notifications from my app?

Jagat Dave
1,6453 gold badges23 silver badges30 bronze badges
asked Jan 14, 2014 at 21:17

2 Answers 2

2

I did same in my application that read notifications don't remain in Application. Buts its not how you think it is.

i Saved Remote Notification in method didReceiveRemoteNotification: in DataBase (Coredata). Everytime i was in NotificationViewController i retrieved from DataBase (Coredata) and when i want to clear them i-e on Reading , deleted that particular Notification form DB.

thats how you should do it.

OR https://developer.apple.com/library/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS7.html#//apple_ref/doc/uid/TP40013162-SW1 Apple says in iOS 7 user can send "silent" push notifications—that is, notifications that do not display alerts or otherwise disturb the user. By receieving this type "silent" in method application:didReceiveRemoteNotification: do this [[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0]; [[UIApplication sharedApplication] cancelAllLocalNotifications];

answered Jan 14, 2014 at 21:33
Sign up to request clarification or add additional context in comments.

7 Comments

Hmm... But seems like when Google and Facebook do it, they do it without me even touching the app. I'm on the lock screen--and I can see the notifications going away. That core data handling only works when the app is open as far as I know?
You want to do it when you select a particular Row in UITable ?
No. I see push notifications on my lock screen. When I do something on the website, the push notifications on my lock screen disappear. That's how it was implemented in these other platforms.
developer.apple.com/library/ios/releasenotes/General/… says in iOS 7 user can send "silent" push notifications—that is, notifications that do not display alerts or otherwise disturb the user. By receieving this type "silent" in method application:didReceiveRemoteNotification: do this [[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0]; [[UIApplication sharedApplication] cancelAllLocalNotifications];
You cannot interact Silent notifications. but in didReceiveRemoteNotification: you can clear/cancel every Notification. You just need to check if Notification is silent then do this [[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0]; [[UIApplication sharedApplication] cancelAllLocalNotifications];
|
2

Just ask your backend to send a push with the payload:

{
 "aps" : {
 "badge" : 0
 },
}
answered Jan 29, 2016 at 3:39

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.