iOS阻止使用XEP-0191的用户

我正在开发iOS的聊天应用程序,并使用openfire xmpp服务器? 我试图阻止用户使用XEP-0191:阻止命令,但得到错误的结果。

error xmlns =“jabber:client”type =“cancel”code =“503”service-unavailable xmlns =“urn:ietf:params:xml:ns:xmpp-stanzas”

因为我知道openfier不支持阻止用户的XEP-0191 。 您需要实施XEP-0016隐私列表。 所以你必须使用这种方法创build隐私列表。

- (void)setListWithName:(NSString *)privacyListName items:(NSArray *)items fromUser:(NSString *)user

你可以使用下面的方法来激活它

- (void)setActiveListName:(NSString *)privacyListName;

请参阅

如何在iOS中阻止与xmpp的朋友?

欲了解更多详情请关注隐私清单

XEP-0016

这对我有用。

 XMPPPrivacy * xmppPrivacy =[[XMPPPrivacy alloc] initWithDispatchQueue:dispatch_get_main_queue()]; [xmppPrivacy activate:[XmppGlobalClass sharedInstance].xmppStream]; [xmppPrivacy addDelegate:self delegateQueue:dispatch_get_main_queue()]; NSMutableArray * arraypriv = [[NSMutableArray alloc]init]; NSMutableDictionary * privdict = [[NSMutableDictionary alloc] init]; [privdict setValue:@"deny" forKey:@"action"]; [privdict setValue:jid forKey:@"jid"]; [arraypriv addObject:privdict]; NSXMLElement *privacyElement; NSMutableArray *arrayPrivacy = [[NSMutableArray alloc] init]; privacyElement = [XMPPPrivacy privacyItemWithType:@"jid" value:[NSString stringWithFormat:@"%@@%@",[arraypriv valueForKey:@"jid"],domainName] action:[NSString stringWithFormat:@"%@",[arraypriv valueForKey:@"action"]] order:0]; [arrayPrivacy addObject:privacyElement]; [XMPPPrivacy blockIQs:privacyElement]; [XMPPPrivacy blockMessages:privacyElement]; [XMPPPrivacy blockPresenceIn:privacyElement]; [XMPPPrivacy blockPresenceOut:privacyElement]; [xmppPrivacy setListWithName:@"public" items:arrayPrivacy]; [xmppPrivacy setActiveListName:@"public"]; 

然后,您将通过代理方法(在XEP-0016中)接收阻止的用户列表,

 - (void)xmppPrivacy:(XMPPPrivacy *)sender didReceiveListWithName:(NSString *)name items:(NSArray *)items;