使用XEP-0191的iOS块用户(iOS block user using XEP-0191)

2019-10-29 13:47发布

我开发的聊天应用程序在iOS和使用的Openfire XMPP服务器? 我试图用XEP-0191以阻止用户:封锁的命令,但在结果得到错误。

错误的xmlns = “胡言乱语:客户端” 类型= “取消” 代码= “503” 服务不可用的xmlns = “瓮:IETF:PARAMS:XML:NS:XMPP协议,叙述”

Answer 1:

据我所知openfier不支持XEP-0191块的用户。 你需要实现XEP-0016的隐私列表。 所以你必须创建privacylist使用此方法。

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

你可以激活它下面的方法

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

并请参阅

如何阻止朋友与XMPP iOS中?

欲了解更多详细的关于隐私列表请按照

XEP-0016



Answer 2:

这对我的作品。

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;


文章来源: iOS block user using XEP-0191
标签: ios xmpp