質問編集履歴
1
DB構造について追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -170,4 +170,23 @@
|
|
170
170
|
この方法だと、全友達とのやり取りの未読数の合計値しか取得できないため、やりたいことが実現できず...
|
171
171
|
https://teratail.com/questions/149399
|
172
172
|
(こちらはカスタムクラスに友達別に情報を分けずに、全友達との全メッセージを入れています。)
|
173
|
-

|
173
|
+

|
174
|
+
|
175
|
+
20190727以下追記
|
176
|
+
|
177
|
+
|
178
|
+
各メッセージはListened変数を有します。
|
179
|
+

|
180
|
+
Collection View内で該当のセルをタップしたら、Firebase上の変数が未読から既読に変わるようにしています。
|
181
|
+
|
182
|
+
```Swift
|
183
|
+
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
184
|
+
|
185
|
+
|
186
|
+
let newValuesForProfile = ["listened": true]
|
187
|
+
|
188
|
+
//タップしたセルが自分に送られたメールであれば、既読に変更
|
189
|
+
if messages[indexPath.row].senderId == self.toID {
|
190
|
+
DBProvider.Instance.dbRef.child("Media_Messages").child(messages[indexPath.row].childkey!).updateChildValues(newValuesForProfile)
|
191
|
+
}
|
192
|
+
```
|