I'm trying to implement chat using Xmpp Framework i have imported the framework successfully and i have connected server also my problem is I'm not able to login the username and password which i have created in server. I'm using Open Fire for xmpp chat their i have created user's but I'm not able login.
MY CODE
- (void)setupStream {
xmppStream = [[XMPPStream alloc] init];
[xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoster addDelegate:self delegateQueue:dispatch_get_main_queue()];
xmppStream.hostName=@"Hostname";
//xmppStream.hostPort=5222;
}
- (void)goOnline {
XMPPPresence *presence = [XMPPPresence presence];
[[self xmppStream] sendElement:presence];
}
- (void)goOffline {
XMPPPresence *presence = [XMPPPresence presenceWithType:@"unavailable"];
[[self xmppStream] sendElement:presence];
}
- (void)disconnect {
[self goOffline];
[xmppStream disconnect];
}
- (BOOL)connect {
[self setupStream];
NSString *jabberID = @"test12";
NSString *myPassword = @"1234567";
if (![xmppStream isDisconnected]) {
return YES;
}
if (jabberID == nil || myPassword == nil) {
return NO;
}
[xmppStream setMyJID:[XMPPJID jidWithString:jabberID]];
// password = myPassword;
NSError *error = nil;
if (![xmppStream connectWithTimeout:XMPPStreamTimeoutNone error:&error])
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:[NSString stringWithFormat:@"Can't connect to server %@", [error localizedDescription]]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
return NO;
}
else
{
NSLog(@"Connection success");
return YES;
}
return YES;
}
xmppStream code
- (void)xmppStreamDidConnect:(XMPPStream *)sender {
NSError *error = nil;
[[self xmppStream] authenticateWithPassword:@"1234567" error:&error];
}
- (void)xmppStreamDidAuthenticate:(XMPPStream *)sender {
[self goOnline];
}
- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq {
return NO;
}
i have done like above code im getting connection seccuss but user not able to login im getting like .
Connection success
<?xml version='1.0'?>
<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' to='app.umeetup.com'>
<stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="app.umeetup.com" id="9da175a8" stream1:lang="en" version="1.0"/>
RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams"><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>CRAM-MD5</mechanism><mechanism>DIGEST-MD5</mechanism></mechanisms><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><auth xmlns="http://jabber.org/features/iq-auth"/><register xmlns="http://jabber.org/features/iq-register"/></stream:features>
SEND: <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="DIGEST-MD5"/>
RECV: <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cmVhbG09ImFwcC51bWVldHVwLmNvbSIsbm9uY2U9IjBSYm13alFDRkplVHNBQXhXdm9DekppQXg2aUM1aXRiYmZHMERiV0QiLHFvcD0iYXV0aCIsY2hhcnNldD11dGYtOCxhbGdvcml0aG09bWQ1LXNlc3M=</challenge>
SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9InRlc3QxMiIscmVhbG09ImFwcC51bWVldHVwLmNvbSIsbm9uY2U9IjBSYm13alFDRkplVHNBQXhXdm9DekppQXg2aUM1aXRiYmZHMERiV0QiLGNub25jZT0iQzNEQzc2NTAtRTREOS00QTBGLUEzQjQtNUEzM0NBQzZEQzBFIixuYz0wMDAwMDAwMSxxb3A9YXV0aCxkaWdlc3QtdXJpPSJ4bXBwL2FwcC51bWVldHVwLmNvbSIscmVzcG9uc2U9ZjEyNjgxN2ViYWIxZGExZGY5ZmE5MmVjMmNjY2QwYjgsY2hhcnNldD11dGYtOA==</response>
RECV: <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>
please someone guide to resolve this issue.
Thanks.