Blog News about what we are doing

Fernando Dobladez

C2DM & APNS Compared

Written by José Rozanec

At one of our current projects we implemented notifications to Android and iOS devices. After describing our experience with APNS and C2DM, we wanted compare them.

  • APNS uses a binary interface over a SSL connection. Is secure but requires to maintain a persistent connection since you may get blacklisted if disconnecting and reconnecting too frequently.
  • C2DM exposes a REST API, to which messages should be posted. Messages to C2DM servers are sent via HTTPS, and from C2DM servers to the devices via an SSL connection.
  • In neither case, sensitive information should be sent through push mechanisms.
  • APNS authenticates through certificates generated at the Program Portal. Different certificates need to be generated for production and sandbox environments, and the app must be signed with the certificate we are interested on (for testing or production). To generate a certificate, you need to be registered as developer.
  • C2DM asks to retrieve a client login auth-token using the email and password with which the developer registered to the c2dm service. The token is used to authenticate C2DM REST requests. Expires periodically, and should be renewed expiration.
  • Feedback on APNS is not well resolved. We get immediate feedback if the packet was malformed, but we needed to poll a feedback service to get information about devices which are no longer active or already uninstalled the application. The data they provide on feedback service is not sufficient: Apple asks you to verify that the application hasn’t recently been re-registered on the identified devices, before stop sending messages to them.
  • C2DM provides immediate feedback when posting the message. If the app is no longer installed, you’ll get a HTTP 200 response with “Error=NotRegistered” in its body. You should remove the corresponding registration_id to stop sending notifications to it.
Displaying notifications
  • APNS is limited to displaying notifications as alerts, sounds or badges. The notification type and data must be coded at server side.
  • C2DM just delivers the notifications. The mobile app developer decides if an action should be performed or the notifications should be displayed and how should be displayed.
  • C2DM requires to implement exponential backoff to retry failed messages. Not required on APNS.
  • APNS provides a sandbox environment to test the notifications. Not provided by C2DM.
  • Currently no quotas apply to APNS. C2DM, on the other side, requires to estimate usage and applies soft limits, which can be increased by contacting Google.