1 Reply Latest reply on Jan 18, 2017 8:15 PM by Hiren

    iOS XMPPFramework Connectivity While Registration

    Hiren

      I am using following code to register a new user from iPhone device

       

          NSError *error = nil;

          [self.xmppStream setMyJID:[XMPPJID jidWithString:[registerUserName stringByAppendingString:hostName]]];

          BOOL success = [[self xmppStream] connectWithTimeout:XMPPStreamTimeoutNone error:&error];

          if(![[self xmppStream] isConnected])

              success = [[self xmppStream] registerWithPassword:registerPassword error:&error];

         

          if (success) { isRegistering = YES; NSLog(@"XMPP Connted While Registration"); }

       

      Following is   "xmppStreamDidConnect" delegate

       

      - (void)xmppStreamDidConnect:(XMPPStream *)sender

      {

          DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);

          isXmppConnected = YES;

         

          NSError *error = nil;

          if (isXmppConnected && isRegistering && [arrRegisterInfo count])

          {

              XMPPPlainAuthentication *plainAuth = [[XMPPPlainAuthentication alloc] initWithStream:self.xmppStream password:registerPassword];

              if (![self.xmppStream authenticate:plainAuth error:&error]) { NSLog(@"Error authenticating: %@", error); DDLogError(@"Error authenticating: %@", error); }

             

              [self customXMPPIQ:arrRegisterInfo iqName:IQ_SEND_REGISTERATION];

              [obj_DataModel setIsContactSynced:NO];

              isRegistering = NO;

          }

          else

          {

              if (![[self xmppStream] authenticateWithPassword:loginPassword error:&error]) { NSLog(@"Error authenticating: %@", error); DDLogError(@"Error authenticating: %@", error); }

             

              [DesignModel stopActivityIndicator:self.navigationController.view];

          }

      }

       

      But while using "registerWithPassword" it always throws error like below

       

      The operation couldn’t be completed. (XMPPStreamErrorDomain error 1.)

      2017-01-18 11:37:50.286 WibrateMe[11604:107396] didNotAuthenticate <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>

       

      And I debug the library and found something into it. Please check attached snap shot.