Android版PC平台的通知通知、平台、Android、PC

2023-09-06 16:31:32 作者:我有疑心病i

我想写一个Android应用程序,将发送通知从移动设备到安装在PC上的客户端应用程序。通知将包含将被客户端解析的数据。该通知是只有一条路。

I want to write an Android app that would send notifications from the mobile device to a client application installed on a PC. The notifications would contain data that would be parsed by the client. The notifications are one way only.

或者换句话说:从一个设备发送数据通知到另一个,共享相同的用户帐户

Or in other words: "Send data notifications from one device to another, sharing the same user account"

什么是最好的通知/短信平台来实现这样的行为?

一些要求:

使用现有[免费]服务器基础设施(GTALK?)移动PC的连接已被普通服务器身份验证设置(没有广播或IP)的通知时间要近实时易于实施 [可选]使用谷歌账号认证

我的要求的任何建设性的反馈意见将AP preciated为好。

Any constructive feedback about my requirement would be appreciated as well.

推荐答案

这听起来像XMPP会适合您的需求。这肯定会允许其他人使用自己的谷歌Talk帐户或其他任何XMPP帐户(例如 jabber.org ),如只要你的'通知'的大小和频率是合理的(这些都是免费服务,毕竟!)。

It sounds like XMPP would fit your requirements. It would certainly allow someone to use their Google Talk account or any other XMPP account (e.g. jabber.org), as long as your 'notifications' are reasonable in size and frequency (these are free services after all!).

您应该能够完成使用现有库这很好。这个职位将在基本的XMPP级别讨论事情,但许多图书馆将做这里所描述的事物提供更高级别的API。

You should be able to accomplish this fine using existing libraries. This post will discuss things at the basic XMPP level, but many libraries will provide higher level APIs for doing the things described here.

这是如何实现各种事情的一些注意事项你想要的:

Some notes on how to achieve various things you want:

一个XMPP帐户每个连接分配一个称为'资源'唯一标识符 。在XMPP一个简单的地址如 user@gmail.com 被称为的裸JID。您还可以通过包括资源, user@gmail.com/your-app829abc (一个全JID')发送到特定的连接。由于资源来来去去,可能会有所不同(谷歌的半随机化它们为例), presence 用于广播可用性和资源不可。

Every connection to an XMPP account is assigned a unique identifier called a 'resource'. In XMPP a simple address like user@gmail.com is called a 'bare JID'. You can also send to a specific connection by including the resource, user@gmail.com/your-app829abc (a 'full JID'). Because resources come and go, and can vary (Google semi-randomizes them for example), presence is used to broadcast availability and unavailability of resources.

桌面客户端需要发送presence,从而使移动客户端可以在网上看到。它还应包括一个优先 -1 在presence,以prevent它接收来自用户的联系人正常的聊天消息。它还应包括或类似的识别信息,使得移动客户端可以分开识别它从能力其他应用,如即时通讯客户端,网络与用户的帐户。

The desktop client needs to send presence, so that the mobile client can see it online. It should also include a priority of '-1' in its presence, to prevent it receiving normal chat messages from the user's contacts. It should also include capabilities or similar identifying information so that the mobile client can identify it apart from other apps, such as IM clients, online with the user's account.

有一点要注意,这可能是也可能不是你想要的,是没有办法的桌面客户端出现脱机。它显然需要发送presence,从而使移动客户端可以找到它,但用户的联系人也将看到它在线(即使用户没有登录其IM客户端)。负优先级prevent它接收IM消息,但是。

One thing to note, that may or may not be what you want, there is no way for the desktop client to appear offline. It obviously needs to send presence, so that the mobile client can locate it, but the user's contacts will also see it online (even if the user is not signed into their IM client). The negative priority will prevent it receiving IM messages, however.

<!-- Desktop sends: -->
<presence>
    <priority>-1</priority>
    <your-app xmlns="http://example.com/your-app" type="desktop" />
</presence>

所以,现在从移动客户端的角度......它需要简单地连接到同一个账户,并且还发出类似presence。发送自己的presence后,它会自动从联系人收到presence以及其他连接相同的帐户,包括桌面客户端的连接。

So now from the mobile client's perspective... it needs to simply connect to the same account, and also send similar presence. After sending its own presence it will automatically receive the presence from contacts and also other connections to the same account, including the desktop client's connection.

<!-- Mobile sends: -->
<presence>
    <priority>-1</priority>
    <your-app xmlns="http://example.com/your-app" type="mobile" />
</presence>

<!-- Mobile receives (among other things): -->
<presence from="user@gmail.com/foo38Bc21e">
    <priority>-1</priority>
    <your-app xmlns="http://example.com/your-app" type="desktop" />    
</presence>

现在你有桌面客户端的全JID。

Now you have the desktop client's full JID.

它可以直接rel=\"nofollow\"> XMPP消息以桌面客户端的全JID发送正常

 
精彩推荐
图片推荐