iOS XMPPFramework未发送状态信息

iOS XMPPFramework未发送状态信息,ios,objective-c,xmpp,xmppframework,Ios,Objective C,Xmpp,Xmppframework,我的xmpp流成功连接,在回调中我尝试发送用户的存在。但是,我一直收到以下错误:错误域=XMPPStreamErrorDomain代码=1“操作无法完成。(XMPPStreamErrorDomain错误1)。” 我的连接方法: - (void)connect { NSString *username = @"masa060295@jabber.web.id"; self.password = @"test123"; [self.xmppStream setMyJID:[

我的xmpp流成功连接,在回调中我尝试发送用户的存在。但是,我一直收到以下错误:错误域=XMPPStreamErrorDomain代码=1“操作无法完成。(XMPPStreamErrorDomain错误1)。”

我的连接方法:

- (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];
    }
}
我的回拨:

- (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];
}

有什么想法吗?

您应该在身份验证完成后发送状态信息。在此回调中执行此操作:

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

      [sender sendElement:presence];
 }