Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions sample/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"src/favicon.ico",
"src/assets",
"src/manifest.webmanifest",
"src/main-sw.js",
"src/firebase-messaging-sw.js"
],
"styles": [
Expand Down Expand Up @@ -120,20 +121,34 @@
"bundleDependencies": true,
"externalDependencies": [
"firebase",
"@firebase/app",
"@firebase/analytics",
"@firebase/analytics-types",
"@firebase/app",
"@firebase/app-types",
"@firebase/auth",
"@firebase/auth-interop-types",
"@firebase/auth-types",
"@firebase/component",
"@firebase/database",
"@firebase/database-types",
"@firebase/firestore",
"@firebase/firestore-types",
"@firebase/functions",
"@firebase/functions-types",
"@firebase/installations",
"@firebase/installations-types",
"@firebase/logger",
"@firebase/messaging",
"@firebase/storage",
"@firebase/messaging-types",
"@firebase/performance",
"@firebase/performance-types",
"@firebase/polyfill",
"@firebase/remote-config",
"@firebase/util"
"@firebase/remote-config-types",
"@firebase/storage",
"@firebase/storage-types",
"@firebase/util",
"@firebase/webchannel-wrapper"
]
},
"configurations": {
Expand Down
72 changes: 0 additions & 72 deletions sample/ngcc.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@angular/router": "~10.1.3",
"@angular/service-worker": "^10.1.3",
"@nguniversal/express-engine": "~10.1.0",
"firebase": "~7.13.2",
"firebase": "^7.21.1",
"first-input-delay": "^0.1.3",
"proxy-polyfill": "^0.3.2",
"rxjs": "~6.6.3",
Expand Down
18 changes: 12 additions & 6 deletions sample/src/app/messaging/messaging.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Component, OnInit } from '@angular/core';
import { AngularFireMessaging } from '@angular/fire/messaging';
import { trace } from '@angular/fire/performance';
import { Observable, fromEvent } from 'rxjs';
import { tap, map, filter } from 'rxjs/operators';
import * as firebase from 'firebase/app';
import 'firebase/messaging';
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
import { SwPush } from '@angular/service-worker';
import { environment } from '../../environments/environment';

@Component({
selector: 'app-messaging',
Expand All @@ -25,8 +24,15 @@ export class MessagingComponent implements OnInit {
message$: Observable<any>;
showRequest = false;

constructor(public readonly messaging: AngularFireMessaging, swPush: SwPush) {
messaging.usePublicVapidKey('BIDPctnXHQDIjcOXxDS6qQcz-QTws7bL8v7UPgFnS1Ky5BZL3jS3-XXfxwRHmAUMOk7pXme7ttOBvVoIfX57PEo').then(() => {
constructor(public readonly messaging: AngularFireMessaging, readonly swpush: SwPush) {
swpush.messages.subscribe(it => console.log('swpush', it));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this just for debugging?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this is in the sample app, so this looks good then! Missed that on the first pass.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it seems FCM has made some changes to the FCM API that have affected us. Experimenting with different variations on Service Workers and FCM in the sample app & will probably revamp those guides shortly.

messaging.usePublicVapidKey(environment.vapidKey).then(async () => {
if (navigator && navigator.serviceWorker) {
const registration = await navigator.serviceWorker.getRegistration();
if (registration) {
await messaging.useServiceWorker(registration);
}
}
this.message$ = messaging.messages;
this.token$ = messaging.tokenChanges.pipe(
trace('token'),
Expand Down
3 changes: 2 additions & 1 deletion sample/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export const environment = {
messagingSenderId: '480362569154',
appId: '1:480362569154:web:2fe6f75104cdfb82f50a5b',
measurementId: 'G-CBRYER9PJR'
}
},
vapidKey: 'BIDPctnXHQDIjcOXxDS6qQcz-QTws7bL8v7UPgFnS1Ky5BZL3jS3-XXfxwRHmAUMOk7pXme7ttOBvVoIfX57PEo'
};
3 changes: 2 additions & 1 deletion sample/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export const environment = {
messagingSenderId: '480362569154',
appId: '1:480362569154:web:2fe6f75104cdfb82f50a5b',
measurementId: 'G-CBRYER9PJR'
}
},
vapidKey: 'BIDPctnXHQDIjcOXxDS6qQcz-QTws7bL8v7UPgFnS1Ky5BZL3jS3-XXfxwRHmAUMOk7pXme7ttOBvVoIfX57PEo'
};

/*
Expand Down
4 changes: 2 additions & 2 deletions sample/src/firebase-messaging-sw.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
importScripts('https://www.gstatic.com/firebasejs/7.13.2/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/7.13.2/firebase-messaging.js');
importScripts('https://www.gstatic.com/firebasejs/7.21.1/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/7.21.1/firebase-messaging.js');

firebase.initializeApp({
apiKey: 'AIzaSyA7CNE9aHbcSEbt9y03QReJ-Xr0nwKg7Yg',
Expand Down
2 changes: 2 additions & 0 deletions sample/src/main-sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
importScripts('/ngsw-worker.js');
importScripts('/firebase-messaging-sw.js');
Loading