Este es el intento de una dependencia usando FireBase para enviar y recibir notificaciones push, debido a como esta hecho tuvimos unos problemas y se deben de seguir unas configuraciones previas para poder usarla, sigue la guía para poder levantar los servicios :v.
npm install firebase @angular/fire --save
- ** Step 1 **
- Las push notifications usan Server Worker browser por lo que se debe registrar en un archivo manifest.json
touch src/manifest.json
- Este ID es el mismo para TODAS las aplicaciones del mundo, así que no lo cambies
{
"gcm_sender_id": "103953800507"
}
- Agregar el manifest.json al index.html y también al angular.json
<link rel="manifest" href="/manifest.json">
"build":{
"builder":"@angular-devkit/build-angular:browser",
"options":{
...
"assets":[
"src/favicon.ico",
"src/assets",
"src/manifest.json" // <-- add this
],
"styles":[
"src/styles.css"
],
"scripts":[
...
]
}
...
}
- ** Step 2 **
- Configurar una variable global en la carpeta environments que se llame "firebaseGC"
export const firebaseGC = {
apiKey: String,
authDomain: String,
databaseURL: String,
projectId: String,
storageBucket: String,
messagingSenderId: String
};
- ** Step 3 **
- Exporta la constante "firebaseGC" en el app.module
@NgModule({
declarations: [
AppComponent
],
imports: [
AngularFireModule.initializeApp(environment.firebaseGC),
NotificationModule.forRoot(environment.firebaseGC)
],
providers: [MessagingService, AsyncPipe],
bootstrap: [AppComponent]
})