I am creating a chat based QuickBlox on the QuickBlox Framework, I want to have block functionality in the application. I read some docs like XMPP and QuickBlox . But that didnβt work out.
There is some logic to maintaining the QBPrivacyList in order to prevent other users from sending messages and blocking them, but I did not succeed.
This is a piece of code, as I maintain a privacy list.
Get a privacy list named @"public" in chat mode logged in
[[QBChat instance] retrievePrivacyListWithName:@"public"];
so if an already created privacy list named "public" will be retrieved in the delegate method
- (void)chatDidReceivePrivacyList:(QBPrivacyList *)privacyList{ NSLog(@"chatDidReceivePrivacyList: %@", privacyList); _blockPrivacyList = privacyList;
//answer
[PrivacyList name: public]items:("type: USER_ID valueForType: 2075213 action: deny" )
Here's how to add another member to your privacy list.
- (void)blockUserWithQBId:(NSUInteger)qbID { QBPrivacyItem *item = [[QBPrivacyItem alloc] initWithType:USER_ID valueForType:qbID action:DENY]; if (_blockPrivacyList) { [_blockPrivacyList addObject:item]; // add new user if already privacy list is there }else _blockPrivacyList = [[QBPrivacyList alloc] initWithName:@"public" items:@[item]]; // create new privacy list if not before created [[QBChat instance] setPrivacyList:_blockPrivacyList]; }
And all the delegate methods work fine and add the member to the privacy list.
- (void)chatDidSetPrivacyListWithName:(NSString *)name{ NSLog(@"chatDidSetPrivacyListWithName %@", name); [[QBChat instance] setDefaultPrivacyListWithName:name];
I get this privacy list perfectly, even kill the application or reinstall it for the same user. so my privacy list code works fine
But some, like other members on my DENY personal list, may send me a message. According to the docs from this http://quickblox.com/developers/SimpleSample-chat_users-ios#Contact_list it should give an error like
"error:Error Domain=com.quickblox.chat Code=503 "Service not available."
So, if the entire privacy list works fine, then how can my blocked users send me messages?
I worked with XMPP on iOS , there is the same problem there if you can give the XMPP logic, which will also work like QuickBlox , since QuickBlox actually uses XMPP .
Any suggestions for this?
source share