简体   繁体   English

什么是XMPP,如何在iOS聊天应用程序中使用它?

[英]What is XMPP, and how can I use it within an iOS chat application?

I want to create a chat client application for iPhone. 我想为iPhone创建一个聊天客户端应用程序。 I've read that the XMPP framework is one of the best to use for this. 我已经读过XMPP框架是最适合这种情况的框架之一。 However, I haven't found much material out there on this, only the XMPPFramework on Google Code and details about it on a wiki. 但是,我没有找到很多关于此的内容,只有Google代码上的XMPPFramework以及维基上有关它的详细信息。

Can anyone explain what XMPP is and how we can use it within our chat application? 任何人都可以解释XMPP是什么以及我们如何在聊天应用程序中使用它? Are there any tutorials or code snippets out there that demonstrate its use? 是否有任何教程或代码片段可以证明它的用途?

XMPP is an open protocol for messaging and presence that most IM clients support. XMPP是大多数IM客户端支持的用于消息传递和在线状态的开放协议。

If you're building a chat app for iOS that needs to interact with other clients, use XMPP. 如果您要为iOS构建需要与其他客户端交互的聊天应用程序,请使用XMPP。 Read up and understand the protocol first, then look at the XMPPFramework Objective-C lib and it should all make sense. 首先阅读并理解协议,然后查看XMPPFramework Objective-C lib,它应该都有意义。 It'll take some time to learn though. 但是,这需要一些时间来学习。

If your chat app needs to only communicate with other installations of your app, then you have a few easier options: 如果您的聊天应用只需要与应用的其他安装进行通信,那么您有一些更简单的选择:

You could open a persistent tcp connection with the server and use that to pass presence and message data back and forth. 您可以打开与服务器的持久tcp连接,并使用它来来回传递状态和消息数据。 You could implement a simple server to do this in node.js, for example, in a relatively small amount of code. 您可以在node.js中实现一个简单的服务器来执行此操作,例如,在相对少量的代码中。

An even easier option is to call a simple http based api when you want to report new messages or presence changes from the iphone and deliver updates via push messages. 当您想要从iphone报告新消息或状态更改并通过推送消息提供更新时,更简单的选择是调用简单的基于http的api。 Push messages are good because when the app is closed you can still deliver the message and when the app is open you can intelligently update your app's interface. 推送消息很好,因为当应用程序关闭时,您仍然可以传递消息,当应用程序打开时,您可以智能地更新应用程序的界面。

It's all about your requirements. 这完全取决于您的要求。

V. Have you implemented XMPP? V.您是否实施了XMPP?
I know it's too late to answer, but as now a days I am working on XMPP iOS app, and now we are having comparatively much information available over XMPP, I feel to write here. 我知道现在回答为时已晚,但是现在我正在开发XMPP iOS应用程序,现在我们在XMPP上提供了相对较多的信息,我想在这里写一下。

Here is one of the best tutorial available for integrating XMPP: 这是集成XMPP的最佳教程之一:

1. Building a jabber client for iOS 1.为iOS构建一个jabber客户端
2. XMPP Messanger for iOS - GitHub 2.适用于iOS的XMPP Messanger - GitHub

It is very powerful and really instant protocol to use for IM (as we all know hoe WhatsApp is using it). 它是非常强大的,真正即时的协议用于IM(因为我们都知道锄头WhatsApp正在使用它)。

We can even integrate OMEMO Encryption for our IM App. 我们甚至可以为我们的IM应用程序集成OMEMO加密。

The most known XMPP iOS framework is XMPPFramework . 最着名的XMPP iOS框架是XMPPFramework It provides a core implementation of RFC-3920 (the XMPP standard). 它提供了RFC-3920(XMPP标准)的核心实现。 The framework is massively parallel and thread-safe. 该框架是大规模并行和线程安全的。 Performance is good thanks to GCD. 由于GCD,性能很好。 It comes with multiple popular extensions (XEP's). 它带有多个流行的扩展 (XEP)。

You can find a very well written Swift tutorial to implement XMPPFramework in your application. 您可以在应用程序中找到一个编写得非常好的Swift教程来实现XMPPFramework。 Here is the first part and the second part 这是第一部分第二部分

Alternative can be: 替代方案可以是:

  • DCXMPP but it hasn't been maintained since 2014. DCXMPP但自2014年以来一直没有维护。
  • Libstrophe which is a C library. Libstrophe是一个C库。 You can find an iOS version here . 你可以在这里找到iOS版本。 Same it hasn't been maintained since 2013 同样,它自2013年以来一直没有得到维护

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM