質問編集履歴

1

DB構造について追記

2019/07/27 13:13

投稿

ishiishiyay
ishiishiyay

スコア33

test CHANGED
File without changes
test CHANGED
@@ -343,3 +343,41 @@
343
343
  (こちらはカスタムクラスに友達別に情報を分けずに、全友達との全メッセージを入れています。)
344
344
 
345
345
  ![イメージ説明](455855a5838478e2bf628732e6ff35b2.jpeg)
346
+
347
+
348
+
349
+ 20190727以下追記
350
+
351
+
352
+
353
+
354
+
355
+ 各メッセージはListened変数を有します。
356
+
357
+ ![イメージ説明](6cf5f1d4988dca3cb09f507f8bfc1085.png)
358
+
359
+ Collection View内で該当のセルをタップしたら、Firebase上の変数が未読から既読に変わるようにしています。
360
+
361
+
362
+
363
+ ```Swift
364
+
365
+ func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
366
+
367
+
368
+
369
+
370
+
371
+ let newValuesForProfile = ["listened": true]
372
+
373
+
374
+
375
+ //タップしたセルが自分に送られたメールであれば、既読に変更
376
+
377
+ if messages[indexPath.row].senderId == self.toID {
378
+
379
+ DBProvider.Instance.dbRef.child("Media_Messages").child(messages[indexPath.row].childkey!).updateChildValues(newValuesForProfile)
380
+
381
+ }
382
+
383
+ ```