1

I have to build an app for Android devices (version 2.2 and above) that, among others, will have to implement push notifications. I know that Google offers the C2DM Service for handling theese type of messages. I have also read a tutorial about C2DM and how to implement this.

My problem is, that according to my application requirements, notifications cannot show up to all devices that are registered but only to specific devices that are on a certain range from a specific lat//lng point.

E.g

display push notifications only on devices that are currently located at lat: 40.22 and lng: 22.1 in a range of 10km

So, what I thought was to send the notification along with a lat/lng point and a specific range. Then, the application will check if its current location is in the desired range. If so, the notification will pop on users screen, if not it will vanish.

  1. What do you think ? Is this a good solution, or can you suggest something better?
  2. Moreover, in case I keep this solution how can i access the user's location inside my broadcast receiver (who accepts the push notification from C2DM service)?
antoniom
  • 3,143
  • 1
  • 37
  • 53
  • 1
    That seems like a good approach. And you'll probably want the broadcast receiver to trigger a service to start up that is capable of grabbing the location. – FoamyGuy Mar 16 '12 at 15:43
  • @Tim How can I trigger the service? Can you provide a sample piece of code? Thanks! – antoniom Mar 16 '12 at 15:48
  • Look at this similar question: http://stackoverflow.com/questions/12081964 – Oleksandr G Dec 13 '13 at 19:24

2 Answers2

0

For sample code check out the following Location Programming Tutorial: http://codecanyon.net/item/push-gcm-with-cordovaphonegap-location/9211866?ref=Vbose88 It covers how to get the Location coordinates and uses a GeoCoder to get the address associated with the Location

0

For sample code check out the following Location Programming Tutorial: http://code.google.com/p/openmobster/wiki/LocationApp

It covers how to get the Location coordinates and uses a GeoCoder to get the address associated with the Location

As for service you can take a look at: http://code.google.com/p/openmobster/wiki/AndroidService

It covers how to start, stop and develop a service component.

However, I think you can just do the Location stuff right from the Broadcast receiver itself without requiring to trigger and added component. Doing it inside a service vs broadcast receiver does not buy you anything extra

my two cents!!!

openmobster
  • 1,027
  • 5
  • 17
  • 1
    Please be careful with the self promotion. Too much and you'll find most of your answers flagged as spam. Seen it many times. Try putting an emphasis on answering the question directly rather than suggesting the asker use your code/libraries/etc. –  Mar 19 '12 at 14:46