送基于所述用户的位置通知 [英] Send notifications based on the users location

查看:72
本文介绍了送基于所述用户的位置通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的我正在开发Android应用程序,我希望能够将通知发送到用户的手机取决于他们的位置。例如,用户在餐馆是本地的当前位置将获取特别优惠的通知。

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.

我想知道这样做的最佳方式? (没有code,只是如何做到这一点的一般结构)。

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:

方法1:

1)让应用程序获取用户的位置,并报告给该服务器每5分钟。
2)如果用户是在该位置的一组半径,它们发送该通知。

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.

2的方式:

1)发出通知,并使用应用广播接收方法/ S在正确的领域过滤和只显示通知用户。

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.

似乎都效率极其低下,因为路1依赖于持续运行的服务,方式2发送通知到应用程序的所有用户,并通知会很区具体的,几乎100%的时间通知将不相关的用户(因此未示出)。

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).

我已经写GCM code和还可以得到用户的位置,我只需要一种方法将它们连接起来。

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.

推荐答案

怎么样'的路1.5 的(1和2的组合)?

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.

一些额外的想法:


  • 如果用户离开宽广范围内时,应用程序可以自动连接
    您的服务再次请求新一批的通知。

  • 您可以使广泛的可配置性,所以用户能够preFER大量通信或更广泛的范围内。

  • 根据用户的速度(例如,如果他(她)是在汽车或行走)中,宽范围的通知可以被调整。

这篇关于送基于所述用户的位置通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆