angular / angular/angularfire

Angularfire and NodeJS firebase chat application by using topics

Abierto
#3,223 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
7.8k
Forks
2.2k
Merge medio
22 h 28 min
PR fusionados (30 d)
6

Descripción

I'm a newbie on the firebase. I'm trying to make a chat application with multiple users and multiple rooms by using `AngularJS` (`angularfire`) for the frontend and `NodeJS` for the backend. I want to send many-to-many notifications. I'll use `topics` for this.

Here are the steps I followed:

1. Register user to firebase (backend-NodeJS)
2. Save user UID to the database (MongoDB)
3. Subscribe this user to the topics (backend-NodeJS)
4. Receive notifications from the topics which user has subscribed (frontend-Angular)

I can listen notifications by using `AngularFireMessaging` module (requesting permission and listening) by using these methods in my app.component.ts:

```typescript
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent implements OnInit {
constructor( private afMessaging: AngularFireMessaging ) { }

ngOnInit(): void {
this.requestPermission();
this.listen();
}

requestPermission() {
this.afMessaging.requestPermission
.pipe(mergeMapTo(this.afMessaging.tokenChanges))
.subscribe(
(token) => { console.log('Permission granted! Save to the server!', token); },
(error) => { console.error(error); },
);
}

listen() {
console.log('messages are being listened');
this.afMessaging.messages
.subscribe((message) => {
console.log("messages from firebase");
console.log(message);
});
}
}
```

But as I understand this just registers the token and listens it.

I know I can use realtime databases of firebase. But the app is already prepared and we're storing users' UIds in the database. Also chat rooms and users' relations are also stored in the database.

I thought I can send notifications to the `topic`s named as `roomId`s. Then I can listen these topics.

But how can I listen these topics? I have `topic`'s names, I have also users' UIds. How can I listen these topics?

Or am I missing something?

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con el flujo de notificaciones en app.component.ts, especialmente con requestPermission() y listen(); después, revisa los pasos de suscripción a topics de NodeJS y las relaciones entre usuarios y salas en MongoDB. La tarea estará terminada cuando se defina cómo suscribirse a los topics de roomId y recibirlos en la aplicación existente de Angular y NodeJS.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angularjs, mongodb, node.js, typescript
Área
backend, databases, frontend
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
20/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.