2
votes

I am developing a chat application using XMPPFramework and Openfire as the server. Users of my app are registering themselves in a different server. I use the Openfire server solely for chat communication.

Right now, I have doubts in the architecture of my chat app.

I wish to add a user into Openfire every time a user registers on my server. For this, I have to write a service in my server to insert registered details into Openfire. Is this structure is okay?.

Another question - is it possible to insert/create a user in Openfire server using Objective-C in iPhone?. Does Openfire have any API for this, or do I have to write an external query for this to insert into Openfire database?

If insertion is possible through iPhone app instead of using external service, could anyone provide me a link to the methodology and codes to use?

2
Have a look at In-band Registration xmpp.org/extensions/xep-0077.htmlMarc

2 Answers

0
votes

In-band registration is surely the best way to do this with XMPP.

0
votes

First check whether initiated xmpstream supports registration via method, 'supportsInBandRegistration'. Basic requirement for registration is that a valid xmpp connection should be present.

If registration is supported, create the below array with elements

NSMutableArray *elements = [NSMutableArray array];
[elements addObject:[NSXMLElement elementWithName:@"username" stringValue:@"userName"]];
[elements addObject:[NSXMLElement elementWithName:@"password" stringValue:[[NSUserDefaults standardUserDefaults] valueForKey:userPassword]]];

and pass through XMPPStream method,

 - (BOOL)registerWithElements:(NSArray *)elements error:(NSError **)errPtr

Registration success can be checked with the following delegate method.

  - (void)xmppStreamDidRegister:(XMPPStream *)sender