2

Is it true that if a user does not have Cloud to Device Messaging (C2DM) in his account the C2DM will not work?

If so, how can I do push notifications without a Google account?

Akram
  • 7,548
  • 8
  • 45
  • 72
user2514963
  • 156
  • 3
  • 19
  • Yes, you are right. There surely are some third party libraries that can provide push notification functionality without C2DM. It will increase the draw on the battery though. – Till Helge Nov 25 '11 at 12:27

1 Answers1

14

The different techniques to send push notifications can be listed as follows

  • Android Cloud to Device Messaging (C2DM) on OS2.2+
  • Other techniques for pre OS2.2 Devices.

Cloud to Device Messaging (C2DM) OS2.2+: The standard push notification method used in the android platform is called Android Cloud to Device Messaging (C2DM). The service provides a simple, lightweight mechanism that a server can use to tell an app to contact the server directly, to fetch updated data.

C2DM allows to send lightweight messages to android apps. The messaging service is not designed for sending a lot of user content via the messages. Rather, it should be used to tell the apps that there is new alert on the server, so that the application can fetch it.

C2DM limitations:

  • The message size limit is 1024 bytes.
  • Google limits the number of messages a sender sends in aggregate, and the number of messages a sender sends to a specific device
  • C2DM makes no guarantees about delivery or the order of messages
  • C2DM requires users to set up their Google account on their mobile devices.
  • C2DM requires devices running Android 2.2 or higher that also have the Market application installed

Server should be

  • Able to use HTTPS to communicate with C2DM Server.
  • Able to communicate with our client.
  • Able to fire off HTTP requests to the C2DM server.
  • Able to handle requests and queue data as needed. For example, it should be able to perform exponential back off.
  • Able to store the ClientLogin Auth token and client registration IDs. The ClientLogin Auth token is included in the header of POST requests that send messages. For more discussion of this topic, see ClientLogin for Installed Applications. The server should store the token and have a policy to refresh it periodically.

Other techniques for pre OS2.2 Devices:

  • Poll rather than push
  • SMS
  • Persistent TCP/IP
  • Third-party offerings

Poll rather than push: Android app can periodically poll the server for new messages from a background local service. The more often you poll the closer you get to the real-time push.

  • Adv: Easy to implement.
  • Disadv: Not real-time.Will kill the battery.

SMS: Android apps can intercept text messages in the android phone.So if a server can send an sms when there is a notification, the android app can receive the sms and then check for new data at server.

  • Adv: easy to implement. Fully real-time updates.
  • Disadv: Can be costly to do.

Ericsson labs provide a hosted service which allows upto 2000Sms's to be sent.

Persistent TCP/IP: The android app initiates a long-lived mostly idle TCP/IP connection with the server and maintains it by occasionally sending keepalive messages. Whenever there is something new on the server, it sends a messages to the phone over the TCP connection.

  • Adv: Fully real-time updates.
  • Disadv: Hard to implement a reliable service on both the phone and the server side. The Android OS is known to be able to kill services when it’s running low on memory, so our notifications service can easily disappear. What happens when our phone goes to sleep? Imagine if all the apps use the same technique . there will be plenty of open connetions which will drain the battery.

Third-party offerings

  • Urban Airship Push : The big disadvantage is that it requires the user install the AirMail app onto their device.
  • The deacon project
  • xtify
  • pushdroid.org
rfsk2010
  • 8,571
  • 4
  • 32
  • 46