Blocklist
When you add a user to your blocklist, you stop receiving direct messages from that user. Key points:
- Blocking is one-directional. If you block user A, user A cannot send you direct messages (receives error 405), but you can still send messages to user A.
- Server API messages bypass the blocklist by default. Set
verifyBlacklistto1in the Server API call to enforce the blocklist.
tip
All blocklist APIs are on NCEngine.userModule.
Add to blocklist
- Swift
- Objective-C
swift
NCEngine.userModule.addToBlocklist(userId: "userId") { error in
if error == nil {
// Blocked
}
}
Objective C
[[NCEngine userModule] addToBlocklistWithUserId:@"userId"
completion:^(NCError *error) {
if (!error) {
// Blocked
}
}];
Remove from blocklist
- Swift
- Objective-C
swift
NCEngine.userModule.removeFromBlocklist(userId: "userId") { error in
if error == nil {
// Removed
}
}
Objective C
[[NCEngine userModule] removeFromBlocklistWithUserId:@"userId"
completion:^(NCError *error) {
if (!error) {
// Removed
}
}];
Check if a user is blocked
- Swift
- Objective-C
swift
NCEngine.userModule.checkBlocked(userId: "userId") { isBlocked, error in
if error == nil {
print("Is blocked: \(isBlocked)")
}
}
Objective C
[[NCEngine userModule] checkBlockedWithUserId:@"userId"
completion:^(BOOL isBlocked, NCError *error) {
if (!error) {
NSLog(@"Is blocked: %d", isBlocked);
}
}];
Get the blocklist
- Swift
- Objective-C
swift
NCEngine.userModule.getBlocklist { userIds, error in
if error == nil {
// userIds contains blocked user IDs
}
}
Objective C
[[NCEngine userModule] getBlocklistWithCompletion:^(NSArray<NSString *> *userIds, NCError *error) {
// userIds contains blocked user IDs
}];