Reputation: 13178
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?
Upvotes: 9
Views: 5241
Reputation: 930
Just ask your backend to send a push with the payload:
{
"aps" : {
"badge" : 0
},
}
Upvotes: 2
Reputation: 4244
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];
Upvotes: 2