Nick Ginanto
Nick Ginanto

Reputation: 32120

Working with APNS in production apps

Using APNS in small environments and low volume notifications is not the problem.

The problem (for me at least) is how to work with APNS limitations in a large, high volume of notifications environment.

APNS has some limitations (by design) that make it harder for smooth work

  1. Constant connecting and disconnecting from the APNS might considered a DOS attack. This leads me to believe I need to batch-send the notifications every few seconds and not have a "real time" sending

  2. There is no knowledge if a notification has arrived or sent succesfully. Only when there is an error, it is returned, and when returned it might not be immediate.

  3. When a notification causes an error (for example due to a bad token) the connection is closed by the APNS, and the rest of the notifications in that batch won't be sent to their destination, but some might still be sent to APNS and then lost forever (no feedback on success, so there is no knowledge what happened to them).

How are real-life production apps work with APNS to work around the mentioned problems? Should I save all notifications that I send and for each to check if an error was returned? Should I put them in a queue? Should I just face the fact that there will be notifications that won't be sent? What is a reasonable time between connections so it won't count as a DOS attack?

(at the moment I use Houston in Ruby for handling notifications)

Upvotes: 1

Views: 210

Answers (2)

Ravi Tailor
Ravi Tailor

Reputation: 189

As you know APNS Service is not reliable. You can use Amazon Simple Notification Service (Amazon SNS).

It is is a fast, flexible, fully managed push notification service that lets you send individual messages or to fan-out messages to large numbers of recipients. Amazon SNS makes it simple and cost effective to send push notifications to mobile device users, email recipients or even send messages to other distributed services. Follow below url for more detail......

https://aws.amazon.com/blogs/aws/push-notifications-to-mobile-devices-using-amazon-sns/

Upvotes: 1

Ajay
Ajay

Reputation: 1622

This is what I found from the Local and Remote Notification Programming Guide

Best Practices for Managing Connections

You may establish multiple connections to the same gateway or to multiple gateway instances. If you need to send a large number of remote notifications, spread them out over connections to several different gateways. This improves performance compared to using a single connection: it lets you send the remote notifications faster, and it lets APNs deliver them faster.

Keep your connections with APNs open across multiple notifications; don’t repeatedly open and close connections. APNs treats rapid connection and disconnection as a denial-of-service attack. You should leave a connection open unless you know it will be idle for an extended period of time—for example, if you only send notifications to your users once a day it is ok to use a new connection each day.

Upvotes: 0

Related Questions