我正在使用xcode 6.2 ios sdk 8.2,使用XMPP和OpenFire Server 3.9.3创建聊天应用程序,现在我正在尝试使用此方法注册新用户
-(BOOL)registerWithElements:(NSArray *)elements error:(NSError **)errPtr
但是在这个方法中,supportsInBandRegistration返回NO
- (BOOL)supportsInBandRegistration
{
__block BOOL result = NO;
dispatch_block_t block = ^{ @autoreleasepool {
// The root element can be properly queried for authentication mechanisms anytime after the
// stream:features are received, and TLS has been setup (if required)
if (state >= STATE_XMPP_POST_NEGOTIATION)
{
NSXMLElement *features = [rootElement elementForName:@"stream:features"];
NSXMLElement *reg = [features elementForName:@"register" xmlns:@"http://jabber.org/features/iq-register"];
result = (reg != nil);
}
}};
if (dispatch_get_specific(xmppQueueTag))
block();
else
dispatch_sync(xmppQueue, block);
return result;
}
如何启用supportsInBandRegistration?
注册代码
NSMutableArray *elements = [NSMutableArray array];
[elements addObject:[NSXMLElement elementWithName:@"username" stringValue:@"abc"]];
[elements addObject:[NSXMLElement elementWithName:@"password" stringValue:@"123"]];
[elements addObject:[NSXMLElement elementWithName:@"name" stringValue:@"abc xyz"]];
[elements addObject:[NSXMLElement elementWithName:@"accountType" stringValue:@"3"]];
// [elements addObject:[NSXMLElement elementWithName:@"deviceToken" stringValue:@"7316E42C-160F-46E2-8980-026C682F1B97"]];
[elements addObject:[NSXMLElement elementWithName:@"email" stringValue:@"abc@bbc.com"]];
[[[self appDelegate] xmppStream] registerWithElements:elements error:nil];
感谢