Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component } from '@angular/core';
- import {AngularFirestore} from 'angularfire2/firestore';
- import {AngularFireAuth} from 'angularfire2/auth';
- /**
- * Generated class for the ColaboradoresComponent component.
- *
- * See https://angular.io/api/core/Component for more info on Angular
- * Components.
- */
- @Component({
- selector: 'colaboradores',
- templateUrl: 'colaboradores.html'
- })
- export class ColaboradoresComponent {
- constructor(public afs: AngularFirestore, private afAuth: AngularFireAuth) {
- }
- ngOnInit(){
- this.sendCollaborationRequest('pedro.braga@ccc.ufcg.edu.br', 'nomeDoProjeto :)', 'idDoProjeto :)');
- }
- //Envia notificacao de colaboracao para um usuario do sistema
- private sendCollaborationRequest(userEmail: String, projectName: String, projectId: String){
- var userRequestedId = 'idDoUsuarioAReceberNotification'
- const notificationsRef = this.afs.collection('notifications');
- const usersRef = this.afs.firestore.collection('users');
- /*usersRef.where('email', '==', userEmail).get()
- .then(snap => userRequestedId = snap.docs[0].id)
- .catch(err => userRequestedId = 'idDoDocumento'); */
- const notification = {
- message: 'Você foi convidado para participar do projeto ' + projectName,
- projectId: projectId,
- seen: false,
- type: 'chat',
- userId: userRequestedId
- }
- notificationsRef.add(notification)
- .then(response => console.log("Notification sent!"))
- .catch(err => console.log('Error while sending notification! id do usuario: ' + this.afAuth.auth.currentUser.uid));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement