I am working on a messaging application and I have a dilemma on how to send data from server to client.
I use a centralized server design, where clients use NSURLConnection to send messages to the server, the server does not store or manage open sockets and cannot send a message to one of the clients. Thus, clients use a timer and request a server every 2 seconds to see if new data is waiting for them.
The problem with this approach is that polling the server every 2 seconds seems to kill the battery very quickly, so I thought that instead of clients, polling the server, use APNS * , so when the server has some new information ** for the client, the server will send a push notification *** to the client, then the client will retrieve data from the server.
* use APNS - if the client allows this, the client can, of course, disable this option. Therefore, I will check if push is enabled every time the application comes to the forefront, and if not, I will return to the polling method.
** New information can be anything from text messages to server administrator messages. (and there are a lot of admin posts ...)
For example, in my application, users can see the status of their friends (online / offline), therefore, if user1 and user2 are friends, and user2 just changes his status from online to offline, then the server should send this new information (admin message = user2_offline) user 1.
*** Server push push notifications sendings are empty (without data / sound), this is just a trigger for receiving new information, so if a push was sent to the client and the client application was close, it will not notice anything. (if the application is running, it will receive new information from the server)
Will this approach work with a massive messaging application requiring massive use of push notifications?
To be more clear, my main concerns are:
1. Is APNS reliable enough so that I can use it as the primary messaging mechanism between client and server?
2. Will Apple approve potentially thousands or hundreds of thousands of push notifications per day from my server?