How to create a Firebase Cloud Messaging app in Angular2

How to create Firebase streaming messages in Angular2 / TypeScript / AngularFire2?

JavaScript is described here: https://firebase.google.com/docs/cloud-messaging/js/client

+7
angular typescript firebase firebase-cloud-messaging angularfire2
source share
1 answer

The firebase.messaging() function accepts an instance of the Firebase application as an optional parameter.

To connect it to AngularFire2 , you can let AngularFire2 initialize the application and instantiate the Firebase application, then enter the application instance (for example, into the service) and pass it to firebase.messaging() as follows:

 import { Inject, Injectable } from "@angular/core"; import { FirebaseApp } from "angularfire2"; import * as firebase from 'firebase'; @Injectable() export class SomeService { private _messaging: firebase.messaging.Messaging; constructor(@Inject(FirebaseApp) private _firebaseApp: firebase.app.App) { this._messaging = firebase.messaging(this._firebaseApp); this._messaging.requestPermission() .then(() => { ... }) .catch((error) => { ... }); } } 

You need to customize the web application manifest mentioned in the article you linked to. This is something that I am not familiar with.

+13
source share

All Articles