2016-11-05 103 views
2

我們正在爲我們的移動聊天應用程序使用ejabberd服務器。 我們正在爲我們的IOS應用程序使用IOS XMPP框架(https://github.com/robbiehanson/XMPPFramework從XMPP獲取離線消息而無需成爲在線

但是我們在執行時遇到問題,我們無法找到解決方案。 我們已經實現了XMPP消息傳遞的各個方面,除了一件事情之外,所有作品都很好:

雖然我們的應用程序是在後臺,但我們的ejabberd服務器向我們發送推送通知以通知我們有關脫機消息。 (僅針對離線消息發送通知)

然後,我們決定實施IOS後臺推送通知功能,以在應用程序處於後臺時獲取脫機消息。

但問題是我們必須成爲在線(發送狀態)以獲取離線消息。 但是,當我們這樣做,它創建了2個不良後果:

  1. 誰發送消息看到我們的存在爲在線(儘管我們是在後臺)
  2. 只是因爲我們正在成爲網上同時申請的一方由於我們處於在線狀態,服務器只能發送離線消息通知,因此我們的服務器無法發送其他人消息的推送通知。

爲了解決這個問題,只有我能想到的是,如果有辦法從xmpp服務器上檢索離線消息而不上網。 有誰知道,如果有沒有辦法做到這一點與XMPP的框架IOS

[編輯] 讓我澄清一下這個問題有點多:

問題不僅僅是多了一個:

問題1 - 推送通知的問題:

1.1 - Server check if the message is sending to an online or offline user. If the user is offline server sends push notification to inform user but if the user is online server doesnt send anything. 
1.2 - When the application is in background and receive notification for offline messages, application become alive(still in background) and become online in order to get offline messages 
1.3 - Because the client became online, server doesnt send the push notifications anymore but the application is still in background so the user cannot be informed about the message he/she received. 

因此爲了解決這些我需要找到一種方法,通過不發送接收離線消息的問題網上存在服務器

問題2 - 信息接收問題

2.1 - Server check if the message is sending to an online or offline user. If the user is offline server sends push notification to inform user but if the user is online server doesnt send anything. 
2.2 - When the application is in background and receive notification for offline messages, application become alive(still in background) and become online in order to get offline messages 
2.3 - When the application became online server sends all offline messages to client but doesnt send the total count of offline messages(At least I cannot get it with IOS XMPPFramework) 
2.4 - So I dont know how much longer the client should stay alive in the background because I dont know the total count of offline messages, so after getting 2-3 messages I have to suspend the application in the background. But in that case there might be buggy situations such as XMPP Framework receive the offline message but I suspend the client application before writing it to database etc... 

爲了找到解決這些問題:

  1. 我需要找到一種方式來獲得唯一1離線消息當我想從服務器
  2. 如果可能我還需要得到這些離線消息,而不會變成在線
+0

有關這個問題的任何想法? – tolgatanriverdi

回答

0

查找到ejabberd_mod_offline_post

  1. 首先配置的客房必須是一個會員制的房間,所有用戶添加爲成員創建之後它,這樣能夠得到一個總。
  2. 將上述模塊添加到ejabberd模塊中。
  3. 實現回調服務來處理回調帖子。

的想法是,當用戶脫機:

  • 在一個對一的情況下,offline_message_hook將提高
  • 在MUC情況下,muc_filter_message將提高,任何一個不在場的可用的離線。

將帖子:

我用它16.06。並有在線路中的源代碼中的錯誤:

... 

Body = xml:get_path_s(Stanza, [{elem, list_to_binary("body")}, cdata]), 

... 

Type = xml:get_tag_attr_s(list_to_binary("type"), Packet), 

Body = xml:get_path_s(Packet, [{elem, list_to_binary("body")}, cdata]), 

... 

我通過添加fxml:固定它們,例如 身體= ˚F XML:get_path_s(節中,[{ELEM,list_to_binary( 「正文」)},CDATA]),

而對於MUC,離線用戶處於 '離線' 字段作爲這種格式, 'user1..user2..user3 ..',你需要做的是將它們從字符串中分離出來。

+0

我已經使用mod_offline_post模塊( mod_interact)但是我不明白你的意思。創建聊天室之後,我邀請用戶加入新創建的組,但除此之外,我不知道如何將它們添加爲成員(可以向我發送關於該鏈接的鏈接?)。另外我不知道你的意思是將上述模型添加到ejabberd模型中並實現回調服務。你能更具體一點嗎? 謝謝 – tolgatanriverdi

+0

mod_interact只支持一對一的離線消息。既然你已經使用它,你知道它是如何工作的。我發佈的這個也支持MUC。不要邀請用戶加入,而是直接將用戶添加到成員列表中。 http://xmpp.org/extensions/xep-0045.html#modifymember – dichen

+0

它是否與最新的ejabberd 16.08版本一起工作。因爲我嘗試使用mod_offline_post來代替,但即使我成功配置它,它也不起作用(不轉發郵件) – tolgatanriverdi

0

我建議你自定義擴展元素添加到您的「背景」的在線狀態,例如

<presence ...> 
<source xmlns:="com.foo#background"/> 
</presence> 

那麼,客戶端,當您收到的存在,不通知,如果擴展元素「source」與xmlns「com.foo#background」存在。

+0

實際上,添加擴展元素並不重要,因爲客戶端不會發送通知。服務器端檢查消息是否是離線消息,它會自動將通知發送給設備,當IOS收到通知時,會自動在設備上顯示該消息。所以我需要找到一個解決方案來獲得離線消息,而不會變成在線或找到一個方法來獲得只有1個離線消息(沒有得到所有的消息) – tolgatanriverdi

+0

我沒有明白,抱歉。問題是關於「其他人在線即使我在後臺上」或其他內容?通過最後的評論,你似乎收到了太多的「離線」消息,你不想獲得更多的消息。因此,只需在離線模式下第一次將羣聊/聊天聊天室移除,或者實施存儲消息但僅顯示第一個消息的「等待模式」(true | false)。它在第一次在後臺啓用自身,在第一次接收並啓用隊列後禁用顯示,然後當輕擊發送所有收到的消息發送到您的GUI對象 – MrPk

+0

我編輯了我的問題,因爲註釋部分不包含那麼多字符串 – tolgatanriverdi