-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(various): NG 10 fixes, Storage & FCM regressions (#2522)
* Use navigator serviceWorker for notifications, as FCM seems to be having trouble with RXJS & Angular * Use more of the `registerX` hacks to work around ngcc tree-shaking. Tapping also seems to help, race condition maybe? * Port the sample app to NG 10 * Add all the firebase packages to the Universal externals, having a bunch of problems with that * Experimenting with overriding the legacy packaging choices of the JS SDK with `ngcc.config` in the sample app, should add to the `ng add` schematic if it proves workable * FCM broke in a minor at some point, getToken now prompts for permission; work around this break for now * Firebase Auth seems to be firing an initial null more often now, add the getRedirectResult work-around for now * Firebase Auth is now failing to load in the server environment entirely, work around by returning `of(null)` * Storage is not firing the last snapshot state before completion, making this API difficult to work with, fixed
- Loading branch information
1 parent
1bf6cc9
commit 7cb6c03
Showing
45 changed files
with
2,403 additions
and
1,349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
module.exports = { | ||
packages: { | ||
"firebase": { | ||
entryPoints: { | ||
".": { override: { main: undefined, browser: undefined } }, | ||
"./analytics": { override: { main: undefined, browser: undefined } }, | ||
"./app": {override: { main: undefined, browser: undefined } }, | ||
"./auth": {override: { main: undefined, browser: undefined } }, | ||
"./database": { override: { main: undefined, browser: undefined } }, | ||
"./firestore": { override: { main: undefined, browser: undefined } }, | ||
"./functions": { override: { main: undefined, browser: undefined } }, | ||
"./installations": { override: { main: undefined, browser: undefined } }, | ||
"./storage": { override: { main: undefined, browser: undefined } }, | ||
"./performance": { override: { main: undefined, browser: undefined } }, | ||
"./remote-config": { override: { main: undefined, browser: undefined } }, | ||
}, | ||
generateDeepReexports: true | ||
}, | ||
"@firebase/analytics": { | ||
entryPoints: { ".": { override : { main: undefined, browser: undefined } } }, | ||
ignorableDeepImportMatchers: [ /@firebase\/app-types\/private/ ] | ||
}, | ||
"@firebase/app": { | ||
entryPoints: { ".": { override : { main: undefined, browser: undefined } } }, | ||
ignorableDeepImportMatchers: [ /@firebase\/app-types\/private/ ] | ||
}, | ||
"@firebase/auth": { | ||
entryPoints: { ".": { override : { main: undefined, browser: undefined } } }, | ||
ignorableDeepImportMatchers: [ /@firebase\/app-types\/private/ ] | ||
}, | ||
"@firebase/component": { | ||
entryPoints: { ".": { override: { main: undefined, browser: undefined } } }, | ||
ignorableDeepImportMatchers: [ /@firebase\/app-types\/private/ ] | ||
}, | ||
"@firebase/database": { | ||
entryPoints: { ".": { override: { main: undefined, browser: undefined } } }, | ||
ignorableDeepImportMatchers: [ /@firebase\/app-types\/private/ ] | ||
}, | ||
"@firebase/firestore": { | ||
entryPoints: { ".": { override: { main: undefined, browser: undefined } } }, | ||
ignorableDeepImportMatchers: [ /@firebase\/app-types\/private/ ] | ||
}, | ||
"@firebase/functions": { | ||
entryPoints: { ".": { override: { main: undefined, browser: undefined } } }, | ||
ignorableDeepImportMatchers: [ /@firebase\/app-types\/private/ ] | ||
}, | ||
"@firebase/installations": { | ||
entryPoints: { ".": { override: { main: undefined, browser: undefined } } }, | ||
ignorableDeepImportMatchers: [ /@firebase\/app-types\/private/ ] | ||
}, | ||
"@firebase/messaging": { | ||
entryPoints: { ".": { override: { main: undefined, browser: undefined } } }, | ||
ignorableDeepImportMatchers: [ /@firebase\/app-types\/private/ ] | ||
}, | ||
"@firebase/storage": { | ||
entryPoints: { ".": { override: { main: undefined, browser: undefined } } }, | ||
ignorableDeepImportMatchers: [ /@firebase\/app-types\/private/ ] | ||
}, | ||
"@firebase/performance": { | ||
entryPoints: { ".": { override: { main: undefined, browser: undefined } } }, | ||
ignorableDeepImportMatchers: [ /@firebase\/app-types\/private/ ] | ||
}, | ||
"@firebase/remote-config": { | ||
entryPoints: { ".": { override: { main: undefined, browser: undefined } } }, | ||
ignorableDeepImportMatchers: [ /@firebase\/app-types\/private/ ] | ||
}, | ||
"@firebase/util": { | ||
entryPoints: { ".": { override: { main: undefined, browser: undefined } } }, | ||
ignorableDeepImportMatchers: [ /@firebase\/app-types\/private/ ] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"$schema": "./node_modules/@angular/service-worker/config/schema.json", | ||
"index": "/index.html", | ||
"assetGroups": [ | ||
{ | ||
"name": "app", | ||
"installMode": "prefetch", | ||
"resources": { | ||
"files": [ | ||
"/favicon.ico", | ||
"/index.html", | ||
"/manifest.webmanifest", | ||
"/*.css", | ||
"/*.js" | ||
] | ||
} | ||
}, { | ||
"name": "assets", | ||
"installMode": "lazy", | ||
"updateMode": "prefetch", | ||
"resources": { | ||
"files": [ | ||
"/assets/**", | ||
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)" | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { MessagingComponent } from './messaging.component'; | ||
|
||
describe('MessagingComponent', () => { | ||
let component: MessagingComponent; | ||
let fixture: ComponentFixture<MessagingComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ MessagingComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(MessagingComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
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 { SwPush } from '@angular/service-worker'; | ||
|
||
@Component({ | ||
selector: 'app-messaging', | ||
template: ` | ||
<p> | ||
Messaging! | ||
{{ token$ | async | json }} | ||
{{ message$ | async | json }} | ||
<button (click)="request()" *ngIf="showRequest">Request FCM token</button> | ||
</p> | ||
`, | ||
styles: [] | ||
}) | ||
export class MessagingComponent implements OnInit { | ||
|
||
token$: Observable<any>; | ||
message$: Observable<any>; | ||
showRequest = false; | ||
|
||
constructor(public readonly messaging: AngularFireMessaging, swPush: SwPush) { | ||
messaging.usePublicVapidKey('BIDPctnXHQDIjcOXxDS6qQcz-QTws7bL8v7UPgFnS1Ky5BZL3jS3-XXfxwRHmAUMOk7pXme7ttOBvVoIfX57PEo').then(() => { | ||
this.message$ = messaging.messages; | ||
this.token$ = messaging.tokenChanges.pipe( | ||
trace('token'), | ||
tap(token => this.showRequest = !token) | ||
); | ||
}); | ||
} | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
request() { | ||
this.messaging.requestPermission.subscribe(console.log, console.error); | ||
} | ||
|
||
} |
Oops, something went wrong.