0
發送按鈕2個信息顯示
這裏是我的didpresssend邏輯 - 2條消息出現在視圖中,但頁面被刷新時,實際上只有1個消息是在我的消息數組。爲什麼當我按下JSQMessagesViewController
- (void)didPressSendButton:(UIButton *)button withMessageText:(NSString *)text senderId:(NSString *)senderId senderDisplayName:(NSString *)senderDisplayName date:(NSDate *)date {
JSQMessage *message = [[JSQMessage alloc] initWithSenderId:senderId senderDisplayName:senderDisplayName date:date text:text];
NSDictionary *firebaseMessage = @{@"avatar":self.avatarURL,@"handle":senderDisplayName,@"message":text,@"profileId":self.profID,@"timestamp":[self getTimestamp]};
[[self.threadRef childByAutoId] setValue:firebaseMessage withCompletionBlock:^(NSError * _Nullable error, FIRDatabaseReference * _Nonnull ref) {
if (!error) {
[self.messages addObject:message];
[self finishSendingMessageAnimated:YES];
[self sendToServer:text];
} else {
//Message Failed
}
}];
}