【问题标题】:How to remove chat history from quickblox dialog iOS?如何从 quickblox 对话框 iOS 中删除聊天记录?
【发布时间】:2017-10-20 10:34:14
【问题描述】:

Quickblox iOS 删除聊天记录

我已在我的应用程序中集成了 Quickblox iOS (Objective-C) SDK 用于聊天模块。

现在,我想清除在一个对话框下完成的所有聊天记录,

以下是从对话框中删除特定聊天消息的代码。但它不会删除所有的聊天记录。


NSSet *mesagesIDs = [NSSet setWithObjects:@"560a7e8ba0eb472a6300004d", @"560a7e9ea28f9a0cda003018", nil];

[QBRequest deleteMessagesWithIDs:mesagesIDs forAllUsers:NO successBlock:^(QBResponse *response) {

} errorBlock:^(QBResponse *response) {

}];

如果有人对我的请求有任何可行的解决方案,请帮助我。

提前致谢!

【问题讨论】:

    标签: ios objective-c chat quickblox


    【解决方案1】:

    您可以从 QBChatDialog 中获取要删除的对话框 ID。

    Objective-C 版本

    - (void)deleteDialogWithID:(NSString *)dialogID {
       __weak __typeof(self) weakSelf = self;
       // Deleting dialog from Quickblox and cache.
       [ServicesManager.instance.chatService deleteDialogWithID:dialogID completion:^(QBResponse *response) {
           if (response.success) {
              __typeof(self) strongSelf = weakSelf;
              [strongSelf.tableView reloadData];
              [SVProgressHUD dismiss];
           } else {
              [SVProgressHUD showErrorWithStatus:@"Can not delete dialog"];
              NSLog(@"can not delete dialog: %@", response.error);
           }
       }];
    }
    

    斯威夫特版本

    // Deletes dialog from server and cache.
    ServicesManager.instance().chatService.deleteDialog(withID: dialog.id!, completion: { (response) -> Void in
        guard response.isSuccess else {
          SVProgressHUD.showError(withStatus: "SA_STR_ERROR_DELETING".localized)
          print(response.error?.error)
          return
        }
      SVProgressHUD.showSuccess(withStatus: "SA_STR_DELETED".localized)
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-09
      • 1970-01-01
      相关资源
      最近更新 更多