0

我正在尝试将用户的存在设置为离开(或目前的任何内容)。我正在使用以下代码,但它似乎没有做任何事情。

XMPPPresence *presence = [XMPPPresence presence];
NSXMLElement *show = [NSXMLElement elementWithName:@"show" stringValue:@"away"];

NSXMLElement *status = [NSXMLElement elementWithName:@"status" stringValue:@"away"];
[presence addChild:show];
[presence addChild:status];
[[self xmppStream] sendElement:presence];

我已经使用 iChat 来确保我的 Ejabberd 服务器上的所有在线状态订阅都是正确的并且可以正常工作。这让我发疯,我错过了什么吗?

4

1 回答 1

2

我想通了,结果发现应用程序没有发送存在,因为我错过了这个:

- (MMApplication *)appDelegate {
    return (MMApplication *)[[UIApplication sharedApplication] delegate];
}
- (XMPPStream *)xmppStream {
    return [[self appDelegate] xmppStream];
}

现在完美运行

于 2012-02-20T08:59:36.173 回答