我正在使用QuickBlox-iOS SDK
進行聊天。登錄/註冊工作完美。另外,我能發送消息,但委託方法chatDidReceiveMessage方法不叫QuickBlox
- (void)chatDidReceiveMessage:(QBChatMessage *)message;
是沒有得到調用。這是我用來設置聊天的代碼。添加以下代碼的appDelegate:
// connect to Chat
[[QBChat instance] addDelegate:self];
QBUUser *currentUser = [QBUUser user];
currentUser.ID = [Global sharedInstance].currentUser.ID;
currentUser.password = @"password";
[[QBChat instance] connectWithUser:currentUser completion:^(NSError * _Nullable error) {
NSLog(@"connect to chat error %@",error);
}];
而下面的代碼我用來發送消息:
QBChatMessage *message = [QBChatMessage message];
message.recipientID=[Global sharedInstance].QBUserID;
message.senderID=[Global sharedInstance].currentUser.ID;
[message setText:messageTextView.text];
message.dateSent = [NSDate date];
NSMutableDictionary *params = [NSMutableDictionary dictionary];
params[@"save_to_history"] = @YES;
[message setCustomParameters:params];
[QBRequest createMessage:message successBlock:^(QBResponse *response, QBChatMessage *createdMessage) {
NSLog(@"success: %@", createdMessage);
} errorBlock:^(QBResponse *response) {
NSLog(@"ERROR: %@", response.error);
}]
我對QuickBlox
儀表板檢查。它顯示所有發送/接收的消息。但是,當我向另一個用戶發送消息時,代理不會被調用。我沒有使用任何額外的服務類(QMServices
),就像他們在其示例項目中使用的那樣。任何幫助,將不勝感激。謝謝
感謝您的回答。這些常量是什麼'kQMCustomParameterDialogID','kQMCustomParameterDialogRoomUpdatedDate','kQMCustomParameterDialogRoomLastMessageDate','kQMCustomParameterDialogType'? –
謝謝。代表現在正在接聽電話。但消息未保存在儀表板的歷史記錄中。它出現在最後一條消息中。但是當點擊查看歷史時。消息沒有顯示在那裏。我不想在我的應用程序中使用核心數據。 –
@SushilSharma控制歷史的變量是自定義參數'save_to_history',在這個例子中,我把它放在那裏。你是否擦除了任何自定義參數? – gaskbr