0
votes

I am developing chat application in iOS and using openfire xmpp server? I am trying to block the user using XEP-0191: Blocking Command but getting error in result.

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

2

2 Answers

1
votes

As i know openfier does not support XEP-0191 for block user. you need to implement XEP-0016 privacy list. so you have to create privacylist using this method.

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

and you can make it active with below method

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

and please refer

How to block friend with xmpp in iOS?

For more detail Regarding privacy list please follow

XEP-0016

0
votes

This works for me.

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"];

Then you will receive the blocked user list in the delegate method (In XEP-0016) ,

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