"Three-minute tutorial" easy to use XMPP for iOS single-chat tutorial (source code included)

Source: Internet
Author: User

Number Code that needs to be modified
1 //
//Prefix header
//
//The contents of this file is implicitly included at the beginning of the every source file.
//

#import<Availability.h>
//ServerIP
#define KXMPPHOST @"115.29.222.253"
//Server Port
#define Khostport5222
//Server name,also user name suffix
#define KHOSTNAME @"paxy.com.cn"
2 //
//
//APPDELEGATE.M
// Corporate ICT
//
//Created by Chenyilong on 14-3-3.
//Copyright (c)yearsBlog Address: http://www.cnblogs.com/ChenYilong. All rights reserved.
//
- (void) Connect
{
//2.read user information from System Preferences
Nsuserdefaults*defaults = [Nsuserdefaults Standarduserdefaults];
//NSString *hostname = [defaults stringforkey:kxmpploginhostnamekey];
nsstring *hostname = khostname ;
NSString*username = [DefaultsStringforkey:Kxmpploginusernamekey];
// if the user name or host is empty, no longer continue
//if (Hostname.length = = 0 | | username.length = = 0) {
if(userName.length == 0) {

// user name and host are empty instructions the user is not logged in, usually the first time the program is run
// Show Login window directly
[
Self Showstoryboardwithboardname:Kloginstoryboardname];

return;
}
[
_xmppstream SetHostName:Kxmpphost];
[_xmppstream Sethostport:Khostport];
_xmppstream.Myjid= [XmppjidJidwithuser: UserNameDomain:HostName Resource:Nil];
// Connection
//Gcdasnycsocketin the framework, all network traffic is asynchronous
Nserror*error =Nil;
if(! [_xmppstreamConnectwithtimeout:XmppstreamtimeoutnoneError: &error]) {
Ddloginfo(@"%@", error.localizeddescription);
}Else{
Ddloginfo(@"Send connection request succeeded");
}
}

3 Server Setup Tutorial:Http://www.cnblogs.com/ChenYilong/p/3587344.htmlBasic Program Introduction (User Login interface) Tutorial:Http://www.cnblogs.com/ChenYilong/p/3587335.htmlOfficial Demo: Iphonexmpp.zip
54.0 KB

If you need help, [email protected] exchange, nine to five (outside of business hours) to log the QQ






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.