如何实现XMPP来发送推送通知

时间:2022-09-02 11:08:17

I would like to use XMPP so that my application will send out updates to an android phone (1.5 and higher). I pretty much want to use XMPP to send push notifications to the phone.

我想使用XMPP,这样我的应用程序就会发送更新到android手机(1.5和更高版本)。我非常希望使用XMPP向手机发送推送通知。

How would i go about achieving this. At the moment my web application is running on apache tomact with a number of servlets so the android phone can access information, but I'm finding it difficult understanding how I could implement XMPP so that I can push information from the server to the client (android phone).

我该如何实现这个目标呢?目前,我的web应用程序运行在apache tomact上,使用了许多servlet,以便android手机能够访问信息,但我发现很难理解如何实现XMPP,以便能够将信息从服务器推送到客户机(android phone)。

I have tested the below tutorial Example of XMPP with Google ID login

我已经用谷歌ID登录测试了下面的XMPP教程示例

It uses Google ID logins. But i need to use my webapplication to do what google implements. Any ideas?

它使用谷歌ID登录。但是我需要使用我的webapplication做谷歌实现的事情。什么好主意吗?

2 个解决方案

#1


12  

That would depend on the nature of your push (is it a point to point or pub sub). In either case, you will need an XMPP server that your clients and application are connected to. This will be the means for your application to send notifications to the clients.

这取决于你推的性质(是点对点还是酒吧分)。在这两种情况下,您都需要一个您的客户端和应用程序连接到的XMPP服务器。这将是应用程序向客户端发送通知的方法。

Not sure what you mean by "I need to use my webapplication to what google implements". Your webapplication would be a client to the xmpp server, just like your phones. You cannot use xmpp to simply talk to your webapplication, unless it happens to be a bosh enabled xmpp server itself, which I would guess is not likely.

不确定您的意思是“我需要使用我的webapplication到谷歌工具”。您的web应用程序将是xmpp服务器的客户端,就像您的手机一样。您不能使用xmpp简单地与web应用程序对话,除非它恰好是一个bosh支持的xmpp服务器本身,我认为这不太可能。

You can use Smack for your client communications, and any one of the many available servers.

您可以使用Smack进行客户端通信,以及许多可用服务器中的任何一个。

If the communication is directed at specific clients, then creating a chat between the application and client is probably the simplest means. If it is more of a broadcast, then you could use either MUC (multi user chat) or pubsub.

如果通信指向特定的客户端,那么在应用程序和客户端之间创建聊天可能是最简单的方法。如果它是一个广播,那么您可以使用MUC(多用户聊天)或pubsub。

#2


1  

Generally, you would implement this as a pub-sub feature. Pub-sub is basically the publish/ subscribe paradigm: you publish something and they receive it.

通常,您可以将其作为发布子特性来实现。pubsub基本上就是发布/订阅范例:你发布了一些东西,他们就会收到。

Assuming you have an XMPP server setup that supports the pub-sub protocol extension (like eJabber), in your app, you would login to that server and subscribe to a node (where your update notifications would be sent), and with your subscription you would have to add a handler to handle any notification on that node.

假设你有一个XMPP服务器设置,支持发布-订阅协议扩展(如eJabber),在你的应用程序,你会登录到服务器和订阅一个节点(你的更新通知将被发送),和你的订阅你必须添加一个处理程序来处理节点的任何通知。

On the server side, when you have something that all of your clients need to know about, you would publish the update to the same node that the clients subscribe to.

在服务器端,当您拥有所有客户端都需要了解的内容时,您将向客户端订阅的相同节点发布更新。

For more info, see http://xmpp.org/extensions/xep-0060.html

有关更多信息,请参见http://xmpp.org/extensions/xep-0060.html。

#1


12  

That would depend on the nature of your push (is it a point to point or pub sub). In either case, you will need an XMPP server that your clients and application are connected to. This will be the means for your application to send notifications to the clients.

这取决于你推的性质(是点对点还是酒吧分)。在这两种情况下,您都需要一个您的客户端和应用程序连接到的XMPP服务器。这将是应用程序向客户端发送通知的方法。

Not sure what you mean by "I need to use my webapplication to what google implements". Your webapplication would be a client to the xmpp server, just like your phones. You cannot use xmpp to simply talk to your webapplication, unless it happens to be a bosh enabled xmpp server itself, which I would guess is not likely.

不确定您的意思是“我需要使用我的webapplication到谷歌工具”。您的web应用程序将是xmpp服务器的客户端,就像您的手机一样。您不能使用xmpp简单地与web应用程序对话,除非它恰好是一个bosh支持的xmpp服务器本身,我认为这不太可能。

You can use Smack for your client communications, and any one of the many available servers.

您可以使用Smack进行客户端通信,以及许多可用服务器中的任何一个。

If the communication is directed at specific clients, then creating a chat between the application and client is probably the simplest means. If it is more of a broadcast, then you could use either MUC (multi user chat) or pubsub.

如果通信指向特定的客户端,那么在应用程序和客户端之间创建聊天可能是最简单的方法。如果它是一个广播,那么您可以使用MUC(多用户聊天)或pubsub。

#2


1  

Generally, you would implement this as a pub-sub feature. Pub-sub is basically the publish/ subscribe paradigm: you publish something and they receive it.

通常,您可以将其作为发布子特性来实现。pubsub基本上就是发布/订阅范例:你发布了一些东西,他们就会收到。

Assuming you have an XMPP server setup that supports the pub-sub protocol extension (like eJabber), in your app, you would login to that server and subscribe to a node (where your update notifications would be sent), and with your subscription you would have to add a handler to handle any notification on that node.

假设你有一个XMPP服务器设置,支持发布-订阅协议扩展(如eJabber),在你的应用程序,你会登录到服务器和订阅一个节点(你的更新通知将被发送),和你的订阅你必须添加一个处理程序来处理节点的任何通知。

On the server side, when you have something that all of your clients need to know about, you would publish the update to the same node that the clients subscribe to.

在服务器端,当您拥有所有客户端都需要了解的内容时,您将向客户端订阅的相同节点发布更新。

For more info, see http://xmpp.org/extensions/xep-0060.html

有关更多信息,请参见http://xmpp.org/extensions/xep-0060.html。