3

I've done an app which uses C2DM pusn notifications. Everything works fine as long as I am connected to the GSM/3G network but when I switch to WiFi it does not always work and I do not receive push notifications.

I understand the technical problems when it comes to WiFi and push (firewalls et c).

My question is if there's any smart solutions for this (Yes I know I could switch to "polling" in my app). Is it possible to use GSM/3G and WiFi at the same time, or is Android already doing this when connecting to WiFi?

/ Henrik

Henrik
  • 1,983
  • 3
  • 28
  • 52
  • C2DM works for me while i'm on WiFi ... AFAIK C2DM is internally using polling too but it's better for device when only one service is polling that's why they made C2DM public (before 2.2 they using it internally in market/other google apps) ... so the only problem is that you WiFi network, it doesn't allow devices to connect to google servers(standard http/https ports i think) ... – Selvin Dec 06 '11 at 11:49

2 Answers2

4

I've worked with C2DM quite a lot this year, and I have seen the issue you are describing. I have also heard it happens with iOS devices. I sometimes find push fails and putting the device into Airplane mode and back out again re-enables push message reception.

But anyway in our case the solution was two-fold:

  1. Replace the device with one that could maintain a push message connection across wifi. In our case we had a test device that was particularly prone to the problem.

  2. Build a polling mechanism as a (slow) backup for C2DM. This obviously means more effort, more code, more battery & data usage, but in our case the resulting app is very reliable as a result, even with some problems with C2DM.

My experience is that C2DM is great generally and when it works it's very, very fast, but it fails about 5-10% of the time for a whole variety of reasons and so any app that relies completely on it is likely to be an unreliable app.

You can't use 3G and wifi at the same time - the device will connect to one network at a time.

If your app absolutely 100% needs to receive the messages, I think you have no alternative than to build your own polling, but perhaps do a slow poll to reduce the resource usage, so your app always works, but push simply adds the benefit of speed.

Ollie C
  • 28,313
  • 34
  • 134
  • 217
0

C2DM uses port 5228. If your wifi network blocks this port you won't get push notifications. You'll get them back as soon as you start using a network that doesn't block them assuming they have not expired.

Aaron Cooley
  • 1,967
  • 15
  • 11