I want to implement XMPP framework in my iOS App, I have completed all the things in (Chatting with other users , showing presence of other users , etc.)
But the problem is , I am unable to get the new user registered from my App. I am using following code for that,
if ([appDel.xmppStream supportsInBandRegistration])
[appDel.xmppStream registerWithPassword:txt_Password.text error:nil];
But for this, supportsInBandRegistration method always returns NO and I dont get called the method never registerWithPassword: .
Help me if any solution available
What server are you using? Some servers support in-band registration even thought they don't send the correct stream:feature according to XEP-0077. Most of them should give the feature in the disco results however.
---- OR ---- You can solve this by following code. It's working fine for me. :
- (void)xmppStream:(XMPPStream *)sender didNotAuthenticate:
(NSXMLElement *)error;
{
NSLog(@"Did not authenticate");
[xmppStream registerWithPassword:[[NSUserDefaults
standardUserDefaults] stringForKey:@"userPassword"] error:nil];
NSError * err = nil;
if(![[self xmppStream] registerWithPassword:password error:&err])
{
NSLog(@"Error registering: %@", err);
}
}
- (void)xmppStreamDidRegister:(XMPPStream *)sender{
NSLog(@"I'm in register method");
}
- (void)xmppStream:(XMPPStream *)sender didNotRegister:(NSXMLElement
*)error{
NSLog(@"Sorry the registration is failed");
}
I declare the registerWithPassword:error: method in didNotAuthenticate: method because after connection to the server it is going to this didNotAuthenticate method through where my registration methods is working fine
I had the same problem that [xmppStream supportsInBandRegistration]
method was returning false because i was passing Jid that was already registered in the server.
[xmppStream setMyJID:[XMPPJID jidWithString:jabberID]];
changes JID worked for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.