在 Android 上使用 XMPP 推送用户通知 - 以任何方式定位这些通知,以免他们转到 Google Talk 等 [英] Using XMPP for push user notifications on Android - any way to target these so they don't go to Google Talk etc

查看:21
本文介绍了在 Android 上使用 XMPP 推送用户通知 - 以任何方式定位这些通知,以免他们转到 Google Talk 等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 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?

推荐答案

JID(Jabber/XMPP ID 和 Google Talk ID)有多种形式.

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

首先是一个裸 JID",例如:user@example.com
其次是完整的 JID",例如:user@example.com/xyz123,其中 xyz123 被称为 资源.

First is a "bare JID", e.g.: user@example.com
Secondly is a "full JID", e.g.: user@example.com/xyz123, where xyz123 is called the resource.

一个用户可以同时从多个客户端登录他们的 XMPP 帐户,只要每个客户端使用唯一的资源即可.使用 Google Talk,通常由服务器分配资源.

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.

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

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.

但您也可以直接向完整的 JID 发送消息.这就是您想要做的,以便只有 user@example.com/my-game-some-unique-ID 收到您的游戏特定消息.

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

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

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

另一种选择—再说一次,如果 GAE 允许这种情况——是发送不同的消息类型.
XMPP 是 eX 可扩展的,这意味着您不必将普通的旧 节发送到最后用户;你可以在里面粘贴一个专门的负载,比如 子节,因为普通的 IM 客户端不知道如何解析你的 代码> 节,它们不向用户显示任何内容.只有您的游戏客户端会解析和理解此信息.

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.

这篇关于在 Android 上使用 XMPP 推送用户通知 - 以任何方式定位这些通知,以免他们转到 Google Talk 等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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