Unable to connect XMPPFramework to Openfire server in iOS

前端 未结 2 1668
萌比男神i
萌比男神i 2021-01-21 20:03

I am working on an iOS chat app where user login to app. I\'ve downloaded XMPPFramework from GitHub XMPPFramework. I am trying to connect XMPP

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-21 20:42

    Hope this still relevant, if not, hopefully it will help others. There are some issues with your code:

    1. I don't see the call to connect, you should add something like this:

      NSError *error = nil;
      if (![_xmppStream connectWithTimeout:XMPPStreamTimeoutNone error:&error]) { 
          UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error connecting"
                                                              message:@"Msg"
                                                             delegate:nil
                                                    cancelButtonTitle:@"Ok"
                                                    otherButtonTitles:nil];
          [alertView show];       
      }
      
    2. Most of the XMPP API is asynchronous.
      You have to set the stream delegate in order to receive events. Check out XMPPStreamDelegate and XMPPStream#addDelegate

    If you don't want to go through the code yourself XMPPStream.h , you can implement all methods of XMPPStreamDelegate and log the events. This will help you understand how the framework works.

    Hope this helps, Yaron

提交回复
热议问题