Skip to content

Specification

dongsheng edited this page Apr 15, 2012 · 3 revisions

AirNotifier

Overview

Apple push notification service requires a server to send payload to APNS server, an iOS device, an app registered to receive notification.

Work flow

  1. Launch the iOS app, the app registers itself to APNs, this requires iOS request a device token from APNS:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
  1. APNS server sends a device token back to iOS, this is the identifier of your device, after this, APNS and your device will keep a long pull connection, if APNS gets anything interesting, it will send bytes to your device, the app will get notification.

  2. Then app has to send the device token to AirNotifier via RESTful API, this is the most reliable way to Register tokens to AirNotifier.

  3. When you want to send something to iOS devices, you can send message with token to AirNotifier's notification interface.

  4. AirNotifier received the message, generate the payload and forward to APNs, APNS got the notification then sends to users

Security and architecture of notification server

  • If this server is widely used worldwide (very likely), the most time the server will be waiting for APNS response, just imagine thousands of messages coming in, but the php script still hanging there waiting for APNS response, it has to be fast. We may consider use non-blocking web server, node.js or tornado
  • It doesn't need database, we only need to keep a queen then send them all out, a NoSQL backend can do the job