Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove single remote notification from Notification Center

Tags:

my app receives remote notification from Apple server.

Is there a way to remove a single remote notification from notification center (the drop-down menu available from iOs 5.0+), when the user taps on it?

enter image description here

Thanks!

like image 873
MaTTP Avatar asked Mar 29 '12 12:03

MaTTP


People also ask

What are remote notifications in Android?

Remote Notifications are notifications sent to a mobile device using a data-channel from a service provider in real-time.

How do I turn off notifications on Notification Center?

Touch and hold the notification, and then tap Settings . Choose your settings: To turn off all notifications, turn off All notifications. Turn on or off notifications you want to receive.

What is remote push notification?

Overview. Use remote notifications (also known as push notifications) to push small amounts of data to devices that use your app, even when your app isn't running. Apps use notifications to provide important information to users. For example, a messaging service sends remote notifications when new messages arrive.


2 Answers

There is no way to remove a specific notification as of iOS SDK 5.0. The way to remove all the notifications from your app so they don't show in the Notification Center when the user opens the app from one of them, is to set the app badge to 0, like this:

[UIApplication sharedApplication].applicationIconBadgeNumber = 0; 

EDIT: on iOS 8, SpringBoard seems to be automatically dismissing a notification when you tap on it on the Notification Center to open the app.

like image 67
Javier Soto Avatar answered Sep 22 '22 17:09

Javier Soto


Here is a suggestion, though it does have its flaws, and I haven't tried it myself:

  • Push a silent notification (contentAvailable:true), don't include a "alert" inside the push, place the alert text in a custom property of the push
  • Handle the incoming push and trigger a local notification, display it immediately
  • If the user clicks the local notification, use the [UIApplication cancelLocalNotification:] which should remove the notification from the notification center.
like image 27
Vamos Avatar answered Sep 22 '22 17:09

Vamos