在 Android 上使用 XMPP 推送用户通知 - 任何方式来定位这些通知,这样他们就不会转到 Google Talk 等

发布于 2024-08-26 06:00:59 字数 193 浏览 1 评论 0原文

我想使用 XMPP 将数据推送到我的客户端,这将转换为用户的通知,并计划使用他们的 google-id 登录我的应用程序。我理解 XMPP 的方式是,它是一条直接发送到地址的简单消息,但我希望客户端将其作为指令获取,并将其转换为游戏状态信息。

对于用户来说,在他们的谷歌聊天中得到一堆命令元组或十六进制垃圾将是非常令人沮丧的!我是否误解了这一切的运作方式?

I want to use XMPP to push data to my client which would translate to a notification for the user, and plan on using their google-id for login to my application. The way I understand XMPP is that its a simple message that goes directly to the adress, but I want the client to get it as instructions and turn it into gamestate information.

It would be very frustrating for a user to get a bunch of command tuples or hex garbage in their google chat! Am I misunderstanding the way this all works?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

粉红×色少女 2024-09-02 06:00:59

JID(Jabber/XMPP ID 以及 Google Talk ID)有多种形式。

第一个是“裸 JID”,例如: [email protected]
其次是“完整的 JID”,例如: [email protected]/xyz123,其中 xyz123 称为资源

只要每个客户端使用唯一的资源,一个用户就可以同时从多个客户端登录其 XMPP 帐户。对于 Google Talk,通常由服务器分配资源。

当您在 XMPP 上与某人交谈时,通常您会使用他们的裸 JID 来处理消息 — 您不关心消息被传递到哪个客户端;您只需关心消息被发送到哪个客户端即可。该人的服务器根据其可用性等将其定向到适当的客户端。

但是您也可以将消息直接发送到完整的 JID。这就是您想要做的,这样只有 [email protected]/my-game-some-unique-ID 接收您的游戏特定消息。

我不知道 Google App Engine API 是否为您提供了这种灵活性:)


另一种选择(如果 GAE 允许的话)是发送不同的消息类型。
XMPP 是 eX 可拉伸的,这意味着您不必在末尾发送普通的旧 节用户;您可以在其中粘贴专门的有效负载,例如 子节,因为常规 IM 客户端不知道如何解析您的 code> 节,它们不会向用户显示任何内容。只有您的游戏客户端才会解析并理解此信息。

JIDs (Jabber/XMPP IDs and therefore Google Talk IDs) have several forms.

First is a "bare JID", e.g.: [email protected]
Secondly is a "full JID", e.g.: [email protected]/xyz123, where xyz123 is called the resource.

One user can be logged into their XMPP account from multiple clients simultaneously, so long as each client uses a unique resource. With Google Talk, usually the server allocates the resource.

When you talk to someone on XMPP normally you address messages using their bare JID — you don't care about which client the message gets delivered to; that person's server directs it to the appropriate client(s) based on their availability etc.

But you can also address a message directly to a full JID. This is what you want to do, so that only [email protected]/my-game-some-unique-ID receives your game-specific messages.

Whether the Google App Engine API gives you this flexibility, I have no idea :)


An alternative — again, if GAE allows this — is to send a different message type.
XMPP is eXtensible, meaning that you don't have to send a plain old <message/> stanza to the end user; you can stick a specialised payload inside there like a <game/> child stanza and, because regular IM clients don't know how to parse your <game/> stanzas, they show nothing to the user. Only your game client will parse and understand this info.

橪书 2024-09-02 06:00:59

“Xtify 有一个开箱即用的解决方案,运行 XMPP 的变体。然后,您可以使用他们的网络服务将通知、自定义数据和意图推送到设备和您的应用程序。我一直在使用更标准的解决方案(推送和管理平台),但推送 API 可以工作并且是免费的。

“Xtify has an out of the box solution that runs a variant of XMPP. You can then use their webservice to push notifications and custom data and intents to the device and your app. I've been using there more standard solution (platform for push and managment), but the push API works and is free.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文