Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send notifications based on the users location

In my android app that I am developing, I would like to be able to send notifications to the user's phone depending on their location. For example, A user gets notifications for special deals at restaurants that are local to their current location.

I would like to know the best way to do this? (Not have the code, just the general structure of how to do it).

I have thought of two possible ways:

Way 1:

1) Have the app get the user location and report it to the server every 5 minutes. 2) If the user is in the set radius of the location, send them the notification.

Way 2:

1) Send out the notifications and use the apps broadcast receiver method/s to filter and only show notifications to users in the correct areas.

Both seem horribly inefficient, as way 1 relies on a constantly running service, and way 2 send notifications to all users of the app, and as notifications will be very area specific, nearly 100% of the time the notification will not be relevant to the user (and therefore not shown).

I have already written GCM code and can also get the users location, I just need a way to link them up.

I hope I have made my question clear.

like image 354
user1804590 Avatar asked Jan 14 '13 12:01

user1804590


1 Answers

How about 'Way 1.5' (a combination of 1 and 2)?

You can grab the location of the user and send it to the service. It will respond with notification using a broad range (eg city wide). The application will only show the notification for the actual range.

But, the application knows the notifications for the broad range, so if the users moves, the application is able to show new notification (within the broad range) without connecting to the service.

Some additional thoughts:

  • If the user leaves the broad range, the application can automatically connect to your service again to request a new batch of notifications.
  • You could make the broad range configurable, so the user is able prefer lots of communications or a broader range.
  • Depending on the speed of the user (eg if (s)he is in a car or walking), the broad range of notification can be adjusted.
like image 116
Veger Avatar answered Oct 07 '22 11:10

Veger