-
-
Notifications
You must be signed in to change notification settings - Fork 191
Specification
Apple push notification service requires a server to send payload to APNS server, an iOS device, an app registered to receive notification.
- 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)];
-
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.
-
Then app has to send the device token to AirNotifier via RESTful API, this is the most reliable way to Register tokens to AirNotifier.
-
When you want to send something to iOS devices, you can send message with token to AirNotifier's notification interface.
-
AirNotifier received the message, generate the payload and forward to APNs, APNS got the notification then sends to users
- 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