Ad

Show Notification List Using "ToastController"

- 1 answer

I need to notify the user right after entering the home screen, a message list from a firebase collection, the field that will be displayed is "text". However, I'll only show the messages they have with the "read" field as false. After the message is apprehended, this message will have the "read" field set to true, so that this message will no longer appear to the user. My problem is when I will present the message, he is only searching for the last document in this collection. For example, I have 3 messages to be displayed, and the system only displays the 3rd ...

Service =>

getMensagem() {
    return this._angularFirestore
      .collection(`usuario/${this.user.uid}/mensagem`,
        ref => ref.where('lida', '==', false))
      .valueChanges({ idField: 'id' });
  }

Inicio.page =>

ngOnInit(): void {
    this._usuarioService.getMensagem()
      .pipe(takeUntil(this.unsubscribeAll))
      .subscribe(mensagens => {
        mensagens.forEach(async str => {
          await this.presentToast(str.texto);
        });
      });
  }

async presentToast(message) {
    const toast = await this._toastController.create({
      message: message,
      duration: 3000,
      position: 'top'
    });

    toast.present();
  }

I need him to present the messages one underneath the other. it would be possible?

Ad

Answer

Ionic toaster isn't designed to show multiple toast messages in stacked form. if there are two toast messages than only and only after 1st toaster, the 2nd will appear.

Ad
source: stackoverflow.com
Ad