1

I am working on an application that must notify the user of a server-initiated event. These notifications are only useful for a short space of time (30-60 seconds). For this reason, I am looking for a method that can both deliver a notification quickly, and, importantly, can somehow invalidate (retract/cancel/timeout) the notification after it has already been delivered.

My understanding is that the APNS is not suitable for this. They 'send and forget', giving no ability to check/modify/delete a notification. This functionality is integral to my app though, so I am open to any suggestions for methods or services that might let me achieve this.

In my mind there are several options:

  1. Server sends notification to user. Server then later sends 'cancel' message to user, which removes the notification.

  2. Server sends notification to user, which has a built in timer. This timer is monitored locally, and once it elapses, the notification is removed.

  3. App periodically polls server and schedules/cancels a local notification according to what the server says.

My preference is option 2, because it is self contained and efficient. One message initiates both the scheduling and cancellation. Option 3 has issues with iOS shutting down the app if it's in the background (not to mention the rate at which it would have to poll the server given the notification would only be useful for ~30 seconds).

Do any services such as Urban Airship offer some functionality that could achieve this? Any other suggestions/complete work around methods? All very appreciated.

Thanks for your time!

Matt

EDIT: In the interests of encouraging out of the box thinking, another idea might be that the server initiates an automated phone call with the app user. If the user answers the call, the required information is given to them. If not, the information is no longer available. Bit wacky, and my instinct is that it would be costly, but I'm open to anything!

  • This [answer](http://stackoverflow.com/a/14046622/1407017) is worth reading. Not exactly same question as yours, but on similar line. – Amar May 15 '13 at 10:11
  • Thanks for the link Amar, it definitely looks useful! I'll have a good read. –  May 15 '13 at 11:44

2 Answers2

2

Anything that happens asynchronously can be done with push notifications as it already provides a unidirectional, instant communication channel between you and your customers, so no need to do strange phone calls (which can interrupt your users' activities, bothering them).

You can go for a dual solution, in which you notify your users of how many unread notifications they have in their inbox. Then can you implement your own in-app message inbox, which connects to your servers and fetches the relevant data (in case it hasn't expired - if it has, just let the user know -).

This way users would be able to know how many notifications have been made available to them, but they could only check the ones that are still valid. UrbanAirship employs this approach for their Rich Push feature.

Apart from this, you need to bear in mind push notifications can be very intrusive for the user, so use them wisely or you'll see your users unsubscribing from them or even worse, uninstalling your app.

  • Thanks for the info! I'm not too worried about being intrusive just yet, as the user initiates any contact with the server. They request that the server contacts them with information, and when the info becomes available, these notifications are sent. I'll have a good think about your proposed method though - it definitely has its merits! Matt –  May 15 '13 at 10:10
1

Well my guess you are out of luck, since your only option is APNS.

  1. There is no support for canceling notifications.
  2. Apps can't access the notifications for the app, only the one the user uses to open the app. Also you can't really run apps in the background is they are not used for location, media, VOIP or need to access some kind accessory.
  3. See my point where you can't really run app in backgroud.

Third party services can not add extra functionality to the APNS server as provided by Apple.

As to your suggest that the server will the app, you can't intercept call, sms,... on iOS. I really you only solution is to build a VOIP app that will call the user when ever the notification needs to be displaid.

Apple has no solution that will suite you needs, guess it will have to be an android app then :S

rckoenes
  • 69,092
  • 8
  • 134
  • 166
  • Thanks rckoenes - hopefully I can find a way to run my app in the background (it does use location services). –  May 15 '13 at 10:13
  • If so you can then poll a server on location change (not with a set interval). Apple suggest that you use on major change to check the location in background as not the drain the battery. But you will have same problem as you will hace to prompt the user with a `UILocalNotification`, but luckily you are able to cancel (and remove) local notifications. Just one thing to look out for, if you app drains the battery with the location in background the review might reject your app or even worse you will get a lot of bad reviews. – rckoenes May 15 '13 at 11:00
  • Thank you again for the great information rckoenes, I really appreciate it! I will look instead at the method provided by ale0xB, as it seems to avoid many of these issues. –  May 15 '13 at 11:24
  • The solution by ale0xB is really great on, the way he described it works just like Facebook. – rckoenes May 15 '13 at 11:45