简体   繁体   English

无法在XMPP聊天应用程序中注册用户

[英]Unable to register user in xmpp chat app

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.) 我想在我的iOS应用程序中实现XMPP框架,我已经完成了(与其他用户聊天,显示其他用户的存在等)中的所有内容。

But the problem is , I am unable to get the new user registered from my App. 但是问题是,我无法从我的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: . 但是,为此,supportsInBandRegistration方法始终返回NO,并且我不会调用该方法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. 某些服务器甚至支持未按规定发送带流注册功能,即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 我在didNotAuthenticate:方法中声明了registerWithPassword:error:方法,因为在连接到服务器后,它将通过我的注册方法正常工作的地方转到此didNotAuthenticate方法

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 supportsInBandRegistration]方法返回false,因为我正在传递已经在服务器中注册的[xmppStream supportsInBandRegistration]

[xmppStream setMyJID:[XMPPJID jidWithString:jabberID]];

changes JID worked for me. 更改JID对我有用。

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

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