当应用程序处于后台时,XMPP客户端必须如何通知新消息? [英] How the XMPP client must notified of new Message, when app is in background?

查看:70
本文介绍了当应用程序处于后台时,XMPP客户端必须如何通知新消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑到OPENFIRE不支持XEP-0357(推送通知),那么客户端必须如何通知新消息?用户连接是否必须始终可用?但是在其他消息传递应用程序(如whatsApp)中,当用户进入后台时,它的存在变成了不可用.另一个问题是开发它不支持Background-SERVICE的iOS版本,就像android中一样. 其他IM客户端在这种情况下会做什么?

Considering OPENFIRE not supports XEP-0357 (Push Notification), then how the client must notified of new messages? Does the user connection must be always AVAILABLE? But in other messaging apps like whatsApp, when user goes to background, it's presence turns into UNAVAILABLE. Other problem is for developing iOS version of it that does not supports BACKGROUND-SERVICE like as in android exists. What the other IM clients do in this situation?

推荐答案

我自己建立了答案. 我在服务器中开发了本地API,用于发送推送通知.此本地API将按jids具有所有用户令牌(当在我的应用中生成令牌时,会通过剩余的数据包将数据包发送到我的API). 当用户离线时,openfire服务器将使用 CallBackOnOffline 插件将包含消息正文以及发送者和接收者的JSON的POST请求发送到我的本地API.然后,API将从db获取目标令牌,并将推送请求发送到FCM.

I founded my answer myself. I developed a local API in my server, to send push notification. This local API will have all the users tokens per jids (when Token generated in my app, sends a packet via rest to my API). When a user is offline, openfire server will use CallBackOnOffline plugin to send POST request containing a JSON of message body and sender and receiver to my local API. Then the API will gets the destination Token from db and sends a request of push to FCM.

注意: CallBackOnOffline 在openfire中存在问题不发送POST请求.我也解决了.如果有人遇到此问题,请对其进行评论,我也会提供解决方案.

Note: CallBackOnOffline has a problem in openfire that not sends POST requests. I solved that too. If anyone faced with this problem, comment it, I'll give it's solution too.

这篇关于当应用程序处于后台时,XMPP客户端必须如何通知新消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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