iOS XMPPFRAJEWARTE NO ENVIANDO PRESENCIA
-
21-12-2019 - |
Pregunta
Mi flujo XMPP se conecta con éxito y en la devolución de llamada Intento enviar la presencia del usuario.Sin embargo, sigo obteniendo este error: Error DIAGNER= XMPPPSTREAMERRORDOMAY CÓDIGO= 1 "La operación no se pudo completar. (Error de XMPPStreamRordomain 1.)"
My Conect Method:
- (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];
}
}
Mi devolución de llamada:
- (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];
}
¿Alguna idea?
Solución
Debe enviar presencia después de que haya terminado la autenticación.Hazlo en esta devolución de llamada:
- (void)xmppStreamDidAuthenticate:(XMPPStream *)sender
{
XMPPPresence *presence = [XMPPPresence presence]; // type="available" is implicit
[sender sendElement:presence];
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow