我正在使用以下参考文献中的QuickBlox SDK
https://quickblox.com/developers/SimpleSample-chat_users-ios
在示例聊天中,我也在进行群组视频聊天。但是当我在下面的代码的帮助下更新特定标签时。比我在quickblox管理面板中看不到更新的值。如果有人更新标签名称而不是请建议我。我使用下面的代码
QBUUser *qbUser = [QBUUser user];
qbUser.ID = 23429378;
NSString *roomName = @"ios group";
qbUser.tags = @[roomName].mutableCopy;
NSArray *arry = [[NSArray alloc]initWithObjects:qbUser, nil];
[QMUsersCache.instance insertOrUpdateUsers:users];
- (BFTask *)insertOrUpdateUsers:(NSArray *)users
{
__weak __typeof(self)weakSelf = self;
return [BFTask taskFromExecutor:[BFExecutor executorWithDispatchQueue:self.queue] withBlock:^id{
__typeof(self) strongSelf = weakSelf;
NSManagedObjectContext* context = [strongSelf backgroundContext];
NSMutableArray *toInsert = [NSMutableArray array];
NSMutableArray *toUpdate = [NSMutableArray array];
//To Insert / Update
for (QBUUser *user in users)
{
CDUser *cachedUser = [CDUser QM_findFirstWithPredicate:IS(@"id", @(user.ID)) inContext:context];
if (cachedUser) {
QBUUser *qbCachedUser = [cachedUser toQBUUser];
if (![user.updatedAt isEqualToDate:qbCachedUser.updatedAt]) {
[toUpdate addObject:user];
}
}
else {
[toInsert addObject:user];
}
}
if (toUpdate.count > 0) {
[strongSelf updateUsers:toUpdate inContext:context];
}
if (toInsert.count > 0) {
[strongSelf insertUsers:toInsert inContext:context];
}
if (toInsert.count + toUpdate.count > 0) {
[context QM_saveToPersistentStoreAndWait];
}
QMSLog(@"[%@] Users to insert %tu, update %tu", NSStringFromClass([weakSelf class]), toInsert.count, toUpdate.count);
return nil;
}];
}
答案 0 :(得分:1)
您的代码只是更新CoreData商店中的用户。
您只能从应用程序更新当前用户:
+ (QBRequest *)updateCurrentUser:(QBUpdateUserParameters *)parameters
successBlock:(nullable void (^)(QBResponse *response, QBUUser * _Nullable user))successBlock
errorBlock:(nullable QBRequestErrorBlock)errorBlock;
如果您想更新其他用户,您应该通过管理面板进行更新。
Sample chat与此问题相关。 API Documentation与此问题相关。