• Empleos
  • Sobre nosotros
  • Empleos
    • Inicio
    • Empleos
    • Cursos y retos
  • Empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Contrata talento tech
    • Blog
    • Comercial
    • Calculadora de salario

0

177
Vistas
Consultar una matriz en firestore

Estoy tratando de implementar mi aplicación móvil con notificaciones locales. Para lograr eso, tengo una función que escucha los cambios realizados en Firestore si se agrega una notificación, la notificación se dispara al usuario. Aquí está el código que tengo:

 const deviceId = Constants.deviceId; Firebase.firestore().collection('notifications').where('user_reads', '!=', [deviceId]).onSnapshot(snapshot => { const {stat} = this.context; snapshot.docChanges().forEach(change => { const doc = change.doc.data(); if (change.type === 'added') { console.log(change.doc.data(), 'added'); //handle notification recived Notifications.addNotificationResponseReceivedListener(async response => { console.log(response.notification.request.identifier); //update read status in notification table and save uid of user who read notification Firebase.firestore().collection('notifications').doc(change.doc.id).update({ user_reads: firebase.firestore.FieldValue.arrayUnion(deviceId), read: true, }); //send user to the new post RootNavigation.navigate(t('SinglePost'), { id: response.notification.request.content.data.data }); }); } else if (change.type === 'modified') { console.log(change.doc.data(), 'modified'); } sendPushNotification(doc.title, doc.body, doc.postId); }) });

¿Cómo puedo hacer que Firestore deje de escuchar los cambios? Guardo deviceId en una matriz en firestore. ¿Cómo puedo condicionar esta matriz para verificar si el dispositivo específico existe para dejar de escuchar los cambios? Aquí está la captura de pantalla ingrese la descripción de la imagen aquí

almost 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda