I am fairly new to angular 2 and Firebase but i managed to create a chat
app
Github repo here <https://github.com/pujan1/temp> and live app goes here
<https://anguchat-eb370.firebaseapp.com/>
My end goal is to create a push notification when there is a new message in
the chat app.
1.
I tried installing ng2-notifications
<https://github.com/flauc/angular2-notifications/blob/master/docs/pushNotifications.md>
but
it is very difficult as i couldn't understand the document.
2.
I tried the solution from this thread
<http://stackoverflow.com/questions/2271156/chrome-desktop-notification-example>
from
stack-overflow as well. but the app wont detect the Notification API (
http://i.imgur.com/5ZAgDAr.png ).
Any help on how to approach this right?
i have added component and module ts file
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
import { Component } from '@angular/core';
import { AngularFire, AuthProviders, AuthMethods, FirebaseListObservable } from 'angularfire2';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
items: FirebaseListObservable<any>;
name: any;
msgVal: string = '';
constructor(public af: AngularFire) {
this.items = af.database.list('/messages', {
query: {
limitToLast: 5
}
});
this.af.auth.subscribe(auth => {
if(auth) {
this.name = auth;
}
});
}
login() {
this.af.auth.login({
provider: AuthProviders.Facebook,
method: AuthMethods.Popup,
});
}
chatSend(theirMessage: string) {
this.items.push({ message: theirMessage, name: this.name.facebook.displayName});
this.msgVal = '';
}
mychange()
{
console.log("change happned"); // updated value
}
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { AngularFireModule} from 'angularfire2';
import {initializeApp,database} from 'firebase';
//import {PushNotificationsModule} from 'angular2-notifications';
import { PushNotificationComponent } from 'ng2-notifications/ng2-notifications';
export const firebaseConfig = {
apiKey: "AIzaSyAQUetWt-pH-WuMTZ-lonP2ykICOl4KiPw",
authDomain: "anguchat-eb370.firebaseapp.com",
databaseURL: "https://anguchat-eb370.firebaseio.com",
storageBucket: "anguchat-eb370.appspot.com",
messagingSenderId: "267732203493"
};
initializeApp(firebaseConfig);
database().ref().on('value', function(snapshot){
var x = snapshot.val()
console.log(x.messages);
});
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
FormsModule,
HttpModule,
AngularFireModule.initializeApp(firebaseConfig)
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }