Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dismissing iOS push notifications remotely

The Gmail app for iOS is able to receive push notifications while the app is not running (as most email apps do).

However, it is also able to clear all Gmail push notifications from the device when the unread count of the user's Inbox becomes zero, even if the app is not running.

Here is an example sequence: 1. Receive a new email in your Gmail account. 2. The iOS device displays a notification for the new message. 3. Go to the Gmail website and open the message (marking the message as "read"). 4. The notification on the iOS device is dismissed.

Note: [[UIApplication sharedApplication] scheduledLocalNotifications] only provides local notifications, i.e. those that were created within the iOS app itself.

As far as Apple's documentation for APNS describes, there is no way to remotely launch an app into the background, and there is no way to dismiss a remote notification.

So, how does the Gmail iOS app make this work?

like image 621
ebi Avatar asked Feb 16 '15 22:02

ebi


People also ask

How do I turn off Apple notifications on other devices?

Stop notifications on iPhone and iPad Here's the steps required: Open Settings > Notifications. Scroll down and select the app you want to disable. Toggle the Allow Notification button to turn them off.

What is the fastest way to dismiss notifications on iPhone?

View, dismiss, clear, and mute notifications Handle a notification you receive while using another app: Tap to view it, then swipe up to dismiss it. Clear notifications: Swipe left on a notification or group of notifications, then tap Clear or Clear All.

Can push notifications be intercepted?

Push notifications, when implemented properly, are resistant to interception or redirection and are, therefore, more secure than SMS.


1 Answers

I was able to clear all of my push notifications as well by pushing this payload, using Parse. I'm guessing as long as you supply content-available and badge, you should be able to do the same. I didn't have to write any other code in the AppDelegate, but I did have to turn on push notifications in the projects target capabilities.

curl -X POST \
-H "X-Parse-Application-Id: xxxxxxxxxxx" \
-H "X-Parse-REST-API-Key: xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
       "data": {
         "content-available": "1",
         "badge":"0",
         "sound":""
       },
       "where": {"something":"something_else"}
     }' \
https://api.parse.com/1/push
like image 152
tyler Avatar answered Sep 23 '22 20:09

tyler