Question

I'm trying to figure out how to create a push notification server for a twitter app. I'd like to be able to set up push notification for mentions, stars, follows, etc etc. This is all possible with the API, as Tweetbot does it. If someone could point me in the direction of creating the actual server part of handing the storing of the usernames and pushing the messages out, that would be great. If there is a tutorial on how to do this that would be grand! I'd like to be able to do this through ruby but any method is completely fine.

Thanks

Was it helpful?

Solution

The way I built my push server was like this:

1) Symfony 2 web framework to build an admin portal to manage my entities (Symfony2 is similar to Ruby)

2) A Node.js server that allows me to maintain a persistent connection to Apple's push notification server. (This Node.js beast is epic I tell ya)

3) Node.js will make a HTTP Post request to my Symfony server asking it for new notifications

4) My Symfony server will receive the response from my Node.js server, finds all the new notifications that needs to be sent and returns JSON formatted list of notifications that needs to be sent, the notification contains the message to be sent and an array of unique push tokens (also selectively of the token environment - development vs production) that is to receive the push notification

5) Finally, my Node.js server receives the JSON data, parses the JSON and sends the notification binary stream to Apple's PNS server through TLS socket stream, asynchronously for high performance throughput :D

This method has allowed me to separate PHP Symfony server to manage my data without interfering with my Node.js push server that is abstracted from any data-related logic. The Node.js push server just needs to know the message that needs to be sent and the array of tokens to send it to. At the same time, I can extend and enhance my notification entities such as token groups (allows me to quickly fetch a bunch of token just by choosing a group e.g. members, friends and if you like, enemies :D), notification date (so the notification can be sent at a future date rather than immediately) and more.

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top