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.
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 you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With