现在的位置: 首页 > 综合 > 正文

Building a Jabber Client for iOS: XMPP Setup

2013年10月04日 ⁄ 综合 ⁄ 共 1315字 ⁄ 字号 评论关闭

转自:http://mobile.tutsplus.com/tutorials/iphone/building-a-jabber-client-for-ios-xmpp-integration/

Welcome to the third installment of our series on building a Jabber client with the iOS SDK. In this tutorial, we will add XMPP functionalities to the Application Delegate. Placing the functionality in the App Delegate will enable us to access XMPP functionalities
from anywhere in the application easily.

Integrating XMPP in the AppDelegate

As mentioned, inserting the XMPP functionality in the App Delegate is a great way to make the functionality easily available throughout the app. At any place in your application code, you can access the App Delegate with the following code snippet:

1
[[UIApplication
sharedApplication] delegate]

The XMPP class will dispatch events by means of protocols which we will define below. This is the list of events handled by this class:

  • The client connected with the server
  • The client authenticated with the server
  • The client received a notification of presence (e.g. a user logged in)
  • The client received a message

Let’s get started by adding the some property to the application delegate. First we need to import some XMPP stuff in the header:

1
#import
"XMPP.h"

This is the minimal set of classes needed to build our application. If you want to digg into something more complex you can checkout the example bundled with the XMPP library repository. Here is our first implementation of this class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
@class

SMBuddyListViewController;
 
@interface

jabberClientAppDelegat

抱歉!评论已关闭.