向ios发送推送通知,以便与离线用户openfire xmpp进行聊天 [英] send push notification to ios for chat to offline user, openfire xmpp

查看:205
本文介绍了向ios发送推送通知,以便与离线用户openfire xmpp进行聊天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用openfire的ios聊天应用程序,我需要做的是当消息(1)因任何原因无法发送时发送推送通知,(2)app处于暂停状态,即不能自己生成通知。

I have an ios chat application that uses openfire, what I need to do is send push notification when the message (1) can't be delivered for any reason, (2) app is in suspended state, i.e. can't generate a notification on its own.

我已经在stackoverflow和其他地方阅读了大部分有关此问题的相关问题/建议,我已经总结了一些解决方案。我不是ios开发人员,也不是几天前我对openfire或xmpp一无所知,所以我担心我对事情的理解可能不完整,我的解决方案可能存在缺陷。

I have read most of the related questions/suggestions on this on stackoverflow and elsewhere and I have concluded few solutions to my problem. I am not an ios developer nor did I know anything about openfire or xmpp before a couple of days, so I am afraid my understanding of things may not be complete and my solutions might be flawed.

请确认我对它的理解并建议我是否遗漏了某些内容或是否有更好的方法。还请建议实施下面列出的特定解决方案的复杂程度。

Kindly confirm my understanding of it and suggest if I am missing something or if there is a better approach. Please also suggest about how complex it is going to be to implement a particular solution listed below.

这里的挑战是确定何时需要推送以及启动流程的位置,所以

Challenge here is to identify when the push is required and where the process be initiated, so

1)一种方法是使用xmpp的xep-0184实现来检查消息是否已传递。要做到这一点,我们应该在ios数据库中有一些带有消息的传递标志,当从另一端收到传递的响应时更新。因此,我们需要在一段时间后检查此标志,如果传递的状态为false,则使用该消息启动推送过程。看起来是一个复杂的解决方案(等待响应..检查标志有一些时滞......不是很令人印象深刻)

1) one way is to use the xep-0184 implementation of xmpp to check if the message is delivered. to do this we should have some delivered flag with message in ios database, which is updated when the delivered response is received form other end. So we need check for this flag after a little while and if the delivered status is false, initiate push process with the message. Looks to be a complicated solution (wait for response.. check flag with some time lag.. not very impressive)

2)更直接的方法是做一些事情在openfire中,当openfire无法传递将其存储在离线表中的消息时,我们可以对该部分进行一些拦截并使用该消息启动推送过程。这看起来是正确的方法,但我真的害怕在openfire中获得那么多东西并改变一些东西(也可能很容易,有人用openfire工作了一点可以说出来吗?)

2) A more straight forward approach is to do something in openfire, when openfire can't deliver a message it stores it in offline table, we can do some interception on that part and initiate the push process with the message. This looks to be the correct approach but I am really afraid of getting that much inside openfire and change something(It might be easy also, somebody who has worked a little with openfire can tell?)

3)这是我的最后一招,这不是解决方案..但如果我无法在预期的时间范围内(从现在起一周内)正确完成,我们计划发送推送通知所有的消息。 oppenfire将保持正常聊天,同时从我们的服务器发送每个消息的推送但是当应用程序在前台时,我们做一些事情来处理不需要显示的额外推送消息,否则只要有一个推送就会收到推送信息。你们怎么看待这种暂时的方式(我们当然必须尽快改变这一点),这是否可行(或者我在这里也遗漏了一些东西)。

3) This is my last resort, and this is not a solution.. but if I can't do it correctly within expected timeframe (which is a week from now) , We plan to send a push notification for all the messages. oppenfire will takecare of normal chat while a push will be sent from our server for each message but when the app is in foreground, we do something to handle the extra push messages that need not be shown, otherwise a push is received whenever there is a message. What do you guys think of this temporary way around (we will of course have to change this as soon as we can), is this doable (or I am missing something here as well).

PS谁能告诉Whatsapp和其他热门应用如何处理这个问题?

P.S. Can anyone tell how Whatsapp and other popular apps handle this?

非常感谢你的帮助。

推荐答案

在整个XMPP会话期间,XMPP需要持久套接字连接或持久BOSH连接。我认为您的挑战是iOS不允许您在后台运行您的应用和套接字。每当您的iOS应用程序进入后台时,iOS会终止您的套接字连接,并且您的Openfire服务器会终止您的XMPP会话。这意味着用户离线。这也是该用户的传入消息进入离线存储的原因。

XMPP requires a persistent socket connection or a "persistent" BOSH connection during your whole XMPP session. I think your challenge is that iOS does not allow you to run your app and socket in background. Whenever your iOS app goes in background iOS kills your socket connection, and your Openfire server kills your XMPP session. This means the user goes offline. Which is also the reason why incoming messages for this user go to the offline storage.

对于此回复感到抱歉,但您建议的所有3种解决方案都是糟糕的黑客;-)。如果你想提出一个好的解决方案,你必须深入到XMPP和iOS。 1周的时间非常短。

Sorry for this response, but all 3 solutions you suggested are terrible hacks ;-). If you want to come up with a good solution you have to go very deep into XMPP and iOS. 1 week is a very short timeframe for this.


有人能告诉Whatsapp和其他热门应用如何处理这个问题吗?

Can anyone tell how Whatsapp and other popular apps handle this?

它们使XMPP会话保持活动状态。这仅适用于经过高度修改的XMPP服务器,其中一些XMPP客户端代理可以在您的应用处于后台时保持会话运行,或者两者兼而有之。

They keep the XMPP session alive. This works only with highly modified XMPP servers, some "XMPP Client Proxy" in between which keeps your session running while your app is in background, or a combination or both.

这篇关于向ios发送推送通知,以便与离线用户openfire xmpp进行聊天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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