Pergunta

Meu xmpp stream liga-se com sucesso e o retorno de chamada de eu tentar enviar a presença do usuário.No entanto, estou recebendo este erro:Erro de Domínio=XMPPStreamErrorDomain Código=1 "A operação não pôde ser concluída.(XMPPStreamErrorDomain de erro 1.)"

O meu método de conectar-se:

- (void)connect {
    NSString *username = @"masa060295@jabber.web.id";
    self.password = @"test123";

    [self.xmppStream setMyJID:[XMPPJID jidWithString:username]];

    NSError *error = nil;
    if (![self.xmppStream connectWithTimeout:XMPPStreamTimeoutNone error:&error])
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
                                                            message:[NSString stringWithFormat:@"Can't connect to server %@", [error localizedDescription]]
                                                           delegate:nil
                                                  cancelButtonTitle:@"Ok"
                                                    otherButtonTitles:nil];
        [alertView show];
    }
}

Meu retorno de chamada:

- (void)xmppStreamDidConnect:(XMPPStream *)sender {
    NSError *error = nil;

    NSLog(@"%hhd", [self.xmppStream isConnected]);

    if (![self.xmppStream authenticateWithPassword:self.password error:&error]) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
                                                            message:[NSString stringWithFormat:@"Can't authenticate %@", [error localizedDescription]]
                                                           delegate:nil
                                                  cancelButtonTitle:@"Ok"
                                                  otherButtonTitles:nil];
        [alertView show];
    }

    XMPPPresence *presence = [XMPPPresence presence];
    NSXMLElement *priority = [NSXMLElement elementWithName:@"priority" numberValue:[NSNumber numberWithInt:127]];
    [presence addChild:priority];

    [self.xmppStream sendElement:presence];
}

Qualquer idéias?

Foi útil?

Solução

Você deve enviar presença, depois de autenticação terminado.Fazê-lo nesta chamada de retorno:

 - (void)xmppStreamDidAuthenticate:(XMPPStream *)sender
 {        
      XMPPPresence *presence = [XMPPPresence presence]; // type="available" is implicit

      [sender sendElement:presence];
 }
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top