Sunday, August 17, 2008

XMPPFramework on iPhone

Several developers have helped recently to make the cocoa xmpp framework compatible with the iPhone. And I'm happy to announce that the changes have been committed, and the framework is now iPhone ready.

Cocoa XMPP Framework Google Code Page

The xcode project in subversion is still a standard desktop project though. You can get a skeleton iPhone project from here.

---UPDATE---

Apparently the iPhone SDK doesn't include the NSXML classes (NSXMLNode, NSXMLElement, NSXMLDocument). This means the framework compiles fine for the simulator, but not for the actual phone.

---UPDATE 2---

I originally thought I might be able to use TouchXML to solve the problem, but this is only for reading XML. There wasn't any support for creating XML, and the XMPP framework does a lot of that. Plus anybody using the framework will heavily depend on the ability to create XML. So I bit the bullet and created a set of NSXML replacement classes for the iPhone with full read AND WRITE support.

---UPDATE 3---

I've received confirmation that the latest changes to the XMPP framework are working on iPhone OS 2.1 and 2.2.

12 comments:

Ryan said...

Awesome contribution, thanks guys!

Anonymous said...

Just to make sure I'm not missing something the iPhone version doesn't have stuff implemented to get the login name/password right?

Robbie Hanson said...

I'm not sure I understand what you're asking. The XMPPFramework supports creating new user accounts, as well as logging in with an existing username and password.

Anonymous said...

Sorry, I was simply asking about the UI to actually tap in the username/pw/server, but then I realized "skeleton" indeed excluded the "flesh". I should have looked into it closer before posting, I just did build/run and all I got was the empty list view, so I wondered if that was normal or not, but poking through the code/xib's, I realize that indeed there is no UI included to input that (like the desktop version).

Anonymous said...

Hi,
Do u have complete script for iphone. like u have xmppframework for desktop.

Thanks

Robbie Hanson said...

You can find instructions on how to incorporate the xmppframework into an iphone framework here.

Dylan Sproule said...

It is possible to show an example of the XMPP connection being constructed from within this project?

Thanks in advance.
Dylan

ikarius said...

XMMPFramework works very well on fast machines likes macs, but on iPhone, when you have to deal with big stanzas (10kb+) containing a lot of xml tags, performance is TERRIBLE !

Mainly because of the repeated parsing of tiny XML fragments.

By TERRIBLE, i mean a throughput of 450b/s instead of an expected 50Kb/s ...

Robbie Hanson said...

Hi ikarius,

Thank you for your constructive criticism. The method in which the XMPP framework parses the XML could most certainly be improved. This doesn't pose a problem for most cases because XMPP is generally used with small xml fragments. Interestingly, the problem is currently easier to fix on the iPhone platform. For more information, and to help out with the fix, please post this problem to the xmpp framework mailing list.

Shinnawy said...

How do i make it work into an actual app?

I have a server using openfire, how do i tell it that this my server, i made a UI with textfields and so, but how to i tell the text field to send that message ?

Jon said...

Well done! where is the donate button ? I also wanted to ask if anyone was going to add XEP 0022 or XEP 0184 to the framework ?

comonitos said...

Can't push
[xmppStream authenticateWithFacebookAccessToken:at error:&error]
to work..

My authentification settings

NSString *fID = [NSString stringWithFormat:@"%@@chat.facebook.com",[[NSUserDefaults standardUserDefaults] objectForKey:@"fbid"]];

//(fbid - facebook user ID)

[xmppStream setHostName:@"chat.facebook.com"];
[xmppStream setHostPort:5222];
[xmppStream setAppId:[Remote FBAppId]];

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

I'm reciving:


ONLY way i can authenticate is
using facebook NICKNAME(!) instead of ID and
- (BOOL)authenticateWithPassword:(NSString *)password error:(NSError **)errPtr

method. please help me!

https://github.com/comonitos/Facebook_Chat_integratoin