0

我试图弄清楚如何为 twitter 应用程序创建推送通知服务器。我希望能够为提及、明星、关注等设置推送通知。这一切都可以通过 API 实现,就像 Tweetbot 一样。如果有人能指出我创建实际服务器部分的方向,即处理用户名的存储并将消息推送出去,那就太好了。如果有关于如何做到这一点的教程,那就太好了!我希望能够通过 ruby​​ 做到这一点,但任何方法都可以。

谢谢

4

1 回答 1

2

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.

于 2012-12-03T09:07:23.683 回答