angular / angular/angularfire

Angularfire and NodeJS firebase chat application by using topics

Đang mở
#3,223 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
7.8k
Fork
2.2k
Merge trung bình
22 giờ 28 phút
Pull request đã merge (30 ngày)
6

Mô tả

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?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với luồng thông báo trong app.component.ts, đặc biệt là requestPermission() và listen(), sau đó xem xét các bước đăng ký topic trong NodeJS và các mối quan hệ giữa người dùng và phòng trong MongoDB. Công việc được hoàn tất khi xác định được cách đăng ký và nhận các topic roomId cho ứng dụng Angular và NodeJS hiện có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angularjs, mongodb, node.js, typescript
Lĩnh vực
backend, databases, frontend
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
20/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.