gpt4 book ai didi

ios - XMPPFramework - 如何更改我的个人资料状态?

转载 作者:行者123 更新时间:2023-11-29 11:04:59 25 4
gpt4 key购买 nike

为了更改我的登录状态,我使用了以下代码:

    XMPPPresence *presence = [XMPPPresence presenceWithType:@"away"];
[[self xmppStream] sendElement:presence];

但我没有得到 [self xmppStream] 的引用。所以我改成了下面的代码:

    XMPPPresence *presence = [XMPPPresence presence];
NSXMLElement *status = [NSXMLElement elementWithName:@"status"];
[status setStringValue:@"away"];
[presence addChild:status];
NSError *error = nil;

xmppStream = [[XMPPStream alloc] init];
[xmppStream disconnect];
NSString *myJID = [NSString stringWithFormat:@"%@", appDelegate.jid];
XMPPJID *JID;
JID = [XMPPJID jidWithString:myJID];
NSLog(@"%@",JID);
[xmppStream setMyJID:JID];
xmppStream.hostName=@"talk.google.com";

[xmppStream connect:&error];
[xmppStream sendElement:presence];

仍然没有得到改变的状态。请分享您的想法。提前致谢。

最佳答案

您可以在通过 goOnline 方法登录后立即更改您的状态,因为它在 xmppStreamDidAuthenticate 之后调用。

- (void)goOnline
{
// Initialize XMPPPresence variable
XMPPPresence *presence = [XMPPPresence presence];

// Initialize XML element <show/> for specifying your status
NSXMLElement *show = [NSXMLElement elementWithName:@"show"];

// Initialize XML element <status/> for describing your status
NSXMLElement *status = [NSXMLElement elementWithName:@"status"];

// If you want your user status to be shown as "Available"
[show setStringValue:@"chat"];
[status setStringValue:@"Available"];

// If you want your user status to be shown as "Busy"
[show setStringValue:@"dnd"];
[status setStringValue:@"Busy"];

// If you want your user status to be shown as "Away"
[show setStringValue:@"away"];
[status setStringValue:@"Away"];

// If you want your user status to be shown as "Off-day"
[show setStringValue:@"xa"];
[status setStringValue:@"Off-day"];

// Add the XML elements to XMPPPresence
[presence addChild:show];
[presence addChild:status];

// Update new presence to server
[xmppStream sendElement:presence];
}

有关我上面的代码的更多信息和解释,请访问 Change XMPPPresence to Away/Busy/Invisible .

关于ios - XMPPFramework - 如何更改我的个人资料状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14079499/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com