簡體   English   中英

如何從quickblox對話框中刪除聊天記錄?

[英]How to remove chat history from quickblox dialog iOS?

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) {

}];

如果有人為我的請求有任何工作解決方案,請幫助我。

提前致謝!

您可以從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);
       }
   }];
}

Swift版本

// 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)
})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM