@angular/fire 16.0.0-rc.0 → 17.0.0-canary.05e9da2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -41
- package/analytics/analytics.module.d.ts +2 -2
- package/analytics/package.json +3 -0
- package/app/app.module.d.ts +2 -2
- package/app/package.json +3 -0
- package/app-check/app-check.module.d.ts +2 -2
- package/app-check/package.json +3 -0
- package/auth/auth.module.d.ts +2 -2
- package/auth/firebase.d.ts +2 -1
- package/auth/package.json +3 -0
- package/auth-guard/package.json +3 -0
- package/compat/analytics/package.json +3 -0
- package/compat/auth/package.json +3 -0
- package/compat/auth-guard/package.json +3 -0
- package/compat/database/package.json +3 -0
- package/compat/firestore/package.json +3 -0
- package/compat/functions/package.json +3 -0
- package/compat/messaging/package.json +3 -0
- package/compat/package.json +3 -0
- package/compat/performance/package.json +3 -0
- package/compat/remote-config/package.json +3 -0
- package/compat/storage/package.json +3 -0
- package/database/database.module.d.ts +2 -2
- package/database/package.json +3 -0
- package/docs/compat/auth/getting-started.md +4 -4
- package/docs/compat/emulators/emulators.md +28 -2
- package/docs/compat/firestore/collections.md +1 -1
- package/docs/compat/firestore/querying-collections.md +2 -2
- package/docs/compat.md +1 -1
- package/docs/install-and-setup.md +1 -1
- package/docs/messaging.md +187 -9
- package/esm2022/analytics/analytics.module.mjs +30 -23
- package/esm2022/analytics/screen-tracking.service.mjs +6 -6
- package/esm2022/analytics/user-tracking.service.mjs +5 -5
- package/esm2022/app/app.module.mjs +28 -22
- package/esm2022/app-check/app-check.module.mjs +25 -23
- package/esm2022/auth/auth.module.mjs +25 -23
- package/esm2022/auth/firebase.mjs +3 -2
- package/esm2022/auth-guard/auth-guard.mjs +5 -5
- package/esm2022/auth-guard/auth-guard.module.mjs +6 -6
- package/esm2022/compat/analytics/analytics.mjs +6 -6
- package/esm2022/compat/analytics/analytics.module.mjs +7 -7
- package/esm2022/compat/analytics/screen-tracking.service.mjs +6 -6
- package/esm2022/compat/analytics/user-tracking.service.mjs +6 -6
- package/esm2022/compat/auth/auth.mjs +6 -6
- package/esm2022/compat/auth/auth.module.mjs +6 -6
- package/esm2022/compat/auth-guard/auth-guard.mjs +5 -5
- package/esm2022/compat/auth-guard/auth-guard.module.mjs +6 -6
- package/esm2022/compat/database/database.mjs +6 -6
- package/esm2022/compat/database/database.module.mjs +6 -6
- package/esm2022/compat/firebase.app.module.mjs +7 -7
- package/esm2022/compat/firestore/firestore.mjs +6 -6
- package/esm2022/compat/firestore/firestore.module.mjs +6 -6
- package/esm2022/compat/functions/functions.mjs +6 -6
- package/esm2022/compat/functions/functions.module.mjs +6 -6
- package/esm2022/compat/messaging/messaging.mjs +6 -6
- package/esm2022/compat/messaging/messaging.module.mjs +6 -6
- package/esm2022/compat/performance/performance.mjs +6 -6
- package/esm2022/compat/performance/performance.module.mjs +7 -7
- package/esm2022/compat/performance/performance.service.mjs +5 -5
- package/esm2022/compat/remote-config/remote-config.mjs +6 -6
- package/esm2022/compat/remote-config/remote-config.module.mjs +6 -6
- package/esm2022/compat/storage/pipes/storageUrl.pipe.mjs +10 -10
- package/esm2022/compat/storage/storage.mjs +6 -6
- package/esm2022/compat/storage/storage.module.mjs +6 -6
- package/esm2022/database/database.module.mjs +27 -25
- package/esm2022/firestore/firestore.module.mjs +27 -25
- package/esm2022/firestore/lite/lite.module.mjs +27 -25
- package/esm2022/functions/functions.module.mjs +27 -25
- package/esm2022/messaging/messaging.module.mjs +29 -22
- package/esm2022/performance/performance.module.mjs +25 -23
- package/esm2022/remote-config/remote-config.module.mjs +29 -22
- package/esm2022/storage/storage.module.mjs +27 -25
- package/esm2022/zones.mjs +5 -5
- package/fesm2022/angular-fire-analytics.mjs +40 -33
- package/fesm2022/angular-fire-analytics.mjs.map +1 -1
- package/fesm2022/angular-fire-app-check.mjs +26 -24
- package/fesm2022/angular-fire-app-check.mjs.map +1 -1
- package/fesm2022/angular-fire-app.mjs +28 -22
- package/fesm2022/angular-fire-app.mjs.map +1 -1
- package/fesm2022/angular-fire-auth-guard.mjs +9 -9
- package/fesm2022/angular-fire-auth-guard.mjs.map +1 -1
- package/fesm2022/angular-fire-auth.mjs +28 -25
- package/fesm2022/angular-fire-auth.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-analytics.mjs +22 -22
- package/fesm2022/angular-fire-compat-analytics.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-auth-guard.mjs +9 -9
- package/fesm2022/angular-fire-compat-auth-guard.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-auth.mjs +10 -10
- package/fesm2022/angular-fire-compat-auth.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-database.mjs +10 -10
- package/fesm2022/angular-fire-compat-database.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-firestore.mjs +10 -10
- package/fesm2022/angular-fire-compat-firestore.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-functions.mjs +10 -10
- package/fesm2022/angular-fire-compat-functions.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-messaging.mjs +11 -11
- package/fesm2022/angular-fire-compat-messaging.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-performance.mjs +16 -16
- package/fesm2022/angular-fire-compat-performance.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-remote-config.mjs +11 -11
- package/fesm2022/angular-fire-compat-remote-config.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-storage.mjs +19 -19
- package/fesm2022/angular-fire-compat-storage.mjs.map +1 -1
- package/fesm2022/angular-fire-compat.mjs +6 -6
- package/fesm2022/angular-fire-compat.mjs.map +1 -1
- package/fesm2022/angular-fire-database.mjs +27 -25
- package/fesm2022/angular-fire-database.mjs.map +1 -1
- package/fesm2022/angular-fire-firestore-lite.mjs +27 -25
- package/fesm2022/angular-fire-firestore-lite.mjs.map +1 -1
- package/fesm2022/angular-fire-firestore.mjs +27 -25
- package/fesm2022/angular-fire-firestore.mjs.map +1 -1
- package/fesm2022/angular-fire-functions.mjs +27 -25
- package/fesm2022/angular-fire-functions.mjs.map +1 -1
- package/fesm2022/angular-fire-messaging.mjs +29 -22
- package/fesm2022/angular-fire-messaging.mjs.map +1 -1
- package/fesm2022/angular-fire-performance.mjs +25 -23
- package/fesm2022/angular-fire-performance.mjs.map +1 -1
- package/fesm2022/angular-fire-remote-config.mjs +29 -22
- package/fesm2022/angular-fire-remote-config.mjs.map +1 -1
- package/fesm2022/angular-fire-storage.mjs +27 -25
- package/fesm2022/angular-fire-storage.mjs.map +1 -1
- package/fesm2022/angular-fire.mjs +4 -4
- package/fesm2022/angular-fire.mjs.map +1 -1
- package/firestore/firestore.module.d.ts +2 -2
- package/firestore/lite/lite.module.d.ts +2 -2
- package/firestore/lite/package.json +3 -0
- package/firestore/package.json +3 -0
- package/functions/functions.module.d.ts +2 -2
- package/functions/package.json +3 -0
- package/messaging/messaging.module.d.ts +2 -2
- package/messaging/package.json +3 -0
- package/package.json +12 -12
- package/performance/package.json +3 -0
- package/performance/performance.module.d.ts +2 -2
- package/remote-config/package.json +3 -0
- package/remote-config/remote-config.module.d.ts +2 -2
- package/schematics/firebaseTools.js +2 -2
- package/schematics/interfaces.js +9 -8
- package/schematics/setup/index.js +46 -47
- package/schematics/setup/prompts.js +24 -19
- package/schematics/utils.js +77 -59
- package/storage/package.json +3 -0
- package/storage/storage.module.d.ts +2 -2
package/README.md
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
|
|
2
2
|
# AngularFire
|
|
3
|
-
The official [Angular](https://angular.io/) library for [Firebase](https://firebase.google.com/).
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
_Note: If you want to ng add AngularFire and will be using Hosting/Cloud Functions, you need to configure the
|
|
8
|
-
Firebase CLI first so that you are logged in for the schematics that are run as part of `ng add @angular/fire`.
|
|
9
|
-
Follow [this guide](docs/install-firebase-tools.md) to have the Firebase CLI walk you through the setup._
|
|
10
|
-
|
|
11
|
-
AngularFire smooths over the rough edges an Angular developer might encounter when implementing the framework-agnostic
|
|
12
|
-
[Firebase JS SDK](https://github.com/firebase/firebase-js-sdk) & aims to provide a more natural developer experience
|
|
4
|
+
AngularFire smooths over the rough edges an Angular developer might encounter when implementing the framework-agnostic
|
|
5
|
+
[Firebase JS SDK](https://github.com/firebase/firebase-js-sdk) & aims to provide a more natural developer experience
|
|
13
6
|
by conforming to Angular conventions.
|
|
14
7
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- **
|
|
8
|
+
<strong><pre>ng add @angular/fire</pre></strong>
|
|
9
|
+
|
|
10
|
+
- **Dependency injection** - Provide and Inject Firebase services in your components.
|
|
11
|
+
- **Zone.js wrappers** - Stable zones allow proper functionality of service workers, forms, SSR, and pre-rendering.
|
|
12
|
+
- **Observable based** - Utilize RxJS rather than callbacks for real-time streams.
|
|
18
13
|
- **NgRx friendly API** - Integrate with NgRx using AngularFire's action based APIs.
|
|
19
|
-
- **Lazy-loading** - AngularFire dynamically imports much of Firebase, reducing time to load your app
|
|
20
|
-
- **Deploy schematics** - Get your Angular application deployed on Firebase Hosting with a single command
|
|
21
|
-
- **Google Analytics** - Zero-effort Angular Router awareness in Google Analytics
|
|
22
|
-
- **Router Guards** - Guard your Angular routes with built-in Firebase Authentication checks
|
|
14
|
+
- **Lazy-loading** - AngularFire dynamically imports much of Firebase, reducing the time to load your app.
|
|
15
|
+
- **Deploy schematics** - Get your Angular application deployed on Firebase Hosting with a single command.
|
|
16
|
+
- **Google Analytics** - Zero-effort Angular Router awareness in Google Analytics.
|
|
17
|
+
- **Router Guards** - Guard your Angular routes with built-in Firebase Authentication checks.
|
|
23
18
|
|
|
24
19
|
## Example use
|
|
25
20
|
|
|
@@ -63,36 +58,14 @@ export class AppComponent {
|
|
|
63
58
|
|
|
64
59
|
constructor() {
|
|
65
60
|
const itemCollection = collection(this.firestore, 'items');
|
|
66
|
-
this.item$ = collectionData(itemCollection);
|
|
61
|
+
this.item$ = collectionData<Item>(itemCollection);
|
|
67
62
|
}
|
|
68
63
|
}
|
|
69
64
|
```
|
|
70
65
|
|
|
71
|
-
## Compatibility
|
|
72
|
-
|
|
73
|
-
### Angular and Firebase versions
|
|
74
|
-
|
|
75
|
-
AngularFire doesn't follow Angular's versioning as Firebase also has breaking changes throughout the year. Instead we try to maintain compatibility with both Firebase and Angular majors for as long as possible, only breaking when we need to support a new major of one or the other.
|
|
76
|
-
|
|
77
|
-
| Angular | Firebase | AngularFire |
|
|
78
|
-
| --------|----------|--------------|
|
|
79
|
-
| 16 | 9 | ^7.6 |
|
|
80
|
-
| 15 | 9 | ^7.5 |
|
|
81
|
-
| 14 | 9 | ^7.4 |
|
|
82
|
-
| 13 | 9 | ^7.2 |
|
|
83
|
-
| 12 | 9 | ^7.0 |
|
|
84
|
-
| 12 | 7,8 | ^6.1.5 |
|
|
85
|
-
| 11 | 7,8 | ^6.1 |
|
|
86
|
-
| 10 | 8 | ^6.0.4 |
|
|
87
|
-
| 10 | 7 | ^6.0.3 |
|
|
88
|
-
| 9 | 8 | ^6.0.4 |
|
|
89
|
-
| 9 | 7 | ^6.0 |
|
|
90
|
-
|
|
91
|
-
<sub>Version combinations not documented here __may__ work but are untested and you will see NPM peer warnings.</sub>
|
|
92
|
-
|
|
93
66
|
### Polyfills
|
|
94
67
|
|
|
95
|
-
Neither AngularFire
|
|
68
|
+
Neither AngularFire nor Firebase ship with polyfills. To have compatibility across a wide-range of environments, we suggest the following polyfills be added to your application:
|
|
96
69
|
|
|
97
70
|
| API | Environments | Suggested Polyfill | License |
|
|
98
71
|
|-----|--------------|--------------------|---------|
|
|
@@ -127,7 +100,7 @@ Get help on our [Q&A board](https://github.com/angular/angularfire/discussions?d
|
|
|
127
100
|
|
|
128
101
|
## Developer Guide
|
|
129
102
|
|
|
130
|
-
This developer guide
|
|
103
|
+
This developer guide assumes you're using the new tree-shakable AngularFire API, [if you're looking for the compatability API you can find the documentation here](docs/compat.md).
|
|
131
104
|
|
|
132
105
|
[See the v7 upgrade guide for more information on this change.](docs/version-7-upgrade.md).
|
|
133
106
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InjectionToken, Injector,
|
|
1
|
+
import { EnvironmentProviders, InjectionToken, Injector, NgZone } from '@angular/core';
|
|
2
2
|
import { FirebaseApp } from '@angular/fire/app';
|
|
3
3
|
import { Analytics as FirebaseAnalytics } from 'firebase/analytics';
|
|
4
4
|
import { Analytics } from './analytics';
|
|
@@ -14,4 +14,4 @@ export declare class AnalyticsModule {
|
|
|
14
14
|
static ɵmod: i0.ɵɵNgModuleDeclaration<AnalyticsModule, never, never, never>;
|
|
15
15
|
static ɵinj: i0.ɵɵInjectorDeclaration<AnalyticsModule>;
|
|
16
16
|
}
|
|
17
|
-
export declare function provideAnalytics(fn: (injector: Injector) => FirebaseAnalytics, ...deps: any[]):
|
|
17
|
+
export declare function provideAnalytics(fn: (injector: Injector) => FirebaseAnalytics, ...deps: any[]): EnvironmentProviders;
|
package/app/app.module.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InjectionToken, Injector,
|
|
1
|
+
import { EnvironmentProviders, InjectionToken, Injector, NgZone } from '@angular/core';
|
|
2
2
|
import { FirebaseApp as IFirebaseApp } from 'firebase/app';
|
|
3
3
|
import { FirebaseApp } from './app';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
@@ -11,4 +11,4 @@ export declare class FirebaseAppModule {
|
|
|
11
11
|
static ɵmod: i0.ɵɵNgModuleDeclaration<FirebaseAppModule, never, never, never>;
|
|
12
12
|
static ɵinj: i0.ɵɵInjectorDeclaration<FirebaseAppModule>;
|
|
13
13
|
}
|
|
14
|
-
export declare function provideFirebaseApp(fn: (injector: Injector) => IFirebaseApp, ...deps: any[]):
|
|
14
|
+
export declare function provideFirebaseApp(fn: (injector: Injector) => IFirebaseApp, ...deps: any[]): EnvironmentProviders;
|
package/app/package.json
ADDED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InjectionToken, Injector,
|
|
1
|
+
import { EnvironmentProviders, InjectionToken, Injector, NgZone } from '@angular/core';
|
|
2
2
|
import { FirebaseApp } from '@angular/fire/app';
|
|
3
3
|
import { AppCheck as FirebaseAppCheck } from 'firebase/app-check';
|
|
4
4
|
import { AppCheck } from './app-check';
|
|
@@ -12,4 +12,4 @@ export declare class AppCheckModule {
|
|
|
12
12
|
static ɵmod: i0.ɵɵNgModuleDeclaration<AppCheckModule, never, never, never>;
|
|
13
13
|
static ɵinj: i0.ɵɵInjectorDeclaration<AppCheckModule>;
|
|
14
14
|
}
|
|
15
|
-
export declare function provideAppCheck(fn: (injector: Injector) => FirebaseAppCheck, ...deps: any[]):
|
|
15
|
+
export declare function provideAppCheck(fn: (injector: Injector) => FirebaseAppCheck, ...deps: any[]): EnvironmentProviders;
|
package/auth/auth.module.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InjectionToken, Injector,
|
|
1
|
+
import { EnvironmentProviders, InjectionToken, Injector, NgZone } from '@angular/core';
|
|
2
2
|
import { FirebaseApp } from '@angular/fire/app';
|
|
3
3
|
import { Auth as FirebaseAuth } from 'firebase/auth';
|
|
4
4
|
import { Auth } from './auth';
|
|
@@ -12,4 +12,4 @@ export declare class AuthModule {
|
|
|
12
12
|
static ɵmod: i0.ɵɵNgModuleDeclaration<AuthModule, never, never, never>;
|
|
13
13
|
static ɵinj: i0.ɵɵInjectorDeclaration<AuthModule>;
|
|
14
14
|
}
|
|
15
|
-
export declare function provideAuth(fn: (injector: Injector) => FirebaseAuth, ...deps: any[]):
|
|
15
|
+
export declare function provideAuth(fn: (injector: Injector) => FirebaseAuth, ...deps: any[]): EnvironmentProviders;
|
package/auth/firebase.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from 'firebase/auth';
|
|
2
|
-
import { applyActionCode as _applyActionCode, beforeAuthStateChanged as _beforeAuthStateChanged, checkActionCode as _checkActionCode, confirmPasswordReset as _confirmPasswordReset, connectAuthEmulator as _connectAuthEmulator, createUserWithEmailAndPassword as _createUserWithEmailAndPassword, deleteUser as _deleteUser, fetchSignInMethodsForEmail as _fetchSignInMethodsForEmail, getAdditionalUserInfo as _getAdditionalUserInfo, getAuth as _getAuth, getIdToken as _getIdToken, getIdTokenResult as _getIdTokenResult, getMultiFactorResolver as _getMultiFactorResolver, getRedirectResult as _getRedirectResult, initializeAuth as _initializeAuth, initializeRecaptchaConfig as _initializeRecaptchaConfig, isSignInWithEmailLink as _isSignInWithEmailLink, linkWithCredential as _linkWithCredential, linkWithPhoneNumber as _linkWithPhoneNumber, linkWithPopup as _linkWithPopup, linkWithRedirect as _linkWithRedirect, multiFactor as _multiFactor, onAuthStateChanged as _onAuthStateChanged, onIdTokenChanged as _onIdTokenChanged, parseActionCodeURL as _parseActionCodeURL, reauthenticateWithCredential as _reauthenticateWithCredential, reauthenticateWithPhoneNumber as _reauthenticateWithPhoneNumber, reauthenticateWithPopup as _reauthenticateWithPopup, reauthenticateWithRedirect as _reauthenticateWithRedirect, reload as _reload, sendEmailVerification as _sendEmailVerification, sendPasswordResetEmail as _sendPasswordResetEmail, sendSignInLinkToEmail as _sendSignInLinkToEmail, setPersistence as _setPersistence, signInAnonymously as _signInAnonymously, signInWithCredential as _signInWithCredential, signInWithCustomToken as _signInWithCustomToken, signInWithEmailAndPassword as _signInWithEmailAndPassword, signInWithEmailLink as _signInWithEmailLink, signInWithPhoneNumber as _signInWithPhoneNumber, signInWithPopup as _signInWithPopup, signInWithRedirect as _signInWithRedirect, signOut as _signOut, unlink as _unlink, updateCurrentUser as _updateCurrentUser, updateEmail as _updateEmail, updatePassword as _updatePassword, updatePhoneNumber as _updatePhoneNumber, updateProfile as _updateProfile, useDeviceLanguage as _useDeviceLanguage, validatePassword as _validatePassword, verifyBeforeUpdateEmail as _verifyBeforeUpdateEmail, verifyPasswordResetCode as _verifyPasswordResetCode } from 'firebase/auth';
|
|
2
|
+
import { applyActionCode as _applyActionCode, beforeAuthStateChanged as _beforeAuthStateChanged, checkActionCode as _checkActionCode, confirmPasswordReset as _confirmPasswordReset, connectAuthEmulator as _connectAuthEmulator, createUserWithEmailAndPassword as _createUserWithEmailAndPassword, deleteUser as _deleteUser, fetchSignInMethodsForEmail as _fetchSignInMethodsForEmail, getAdditionalUserInfo as _getAdditionalUserInfo, getAuth as _getAuth, getIdToken as _getIdToken, getIdTokenResult as _getIdTokenResult, getMultiFactorResolver as _getMultiFactorResolver, getRedirectResult as _getRedirectResult, initializeAuth as _initializeAuth, initializeRecaptchaConfig as _initializeRecaptchaConfig, isSignInWithEmailLink as _isSignInWithEmailLink, linkWithCredential as _linkWithCredential, linkWithPhoneNumber as _linkWithPhoneNumber, linkWithPopup as _linkWithPopup, linkWithRedirect as _linkWithRedirect, multiFactor as _multiFactor, onAuthStateChanged as _onAuthStateChanged, onIdTokenChanged as _onIdTokenChanged, parseActionCodeURL as _parseActionCodeURL, reauthenticateWithCredential as _reauthenticateWithCredential, reauthenticateWithPhoneNumber as _reauthenticateWithPhoneNumber, reauthenticateWithPopup as _reauthenticateWithPopup, reauthenticateWithRedirect as _reauthenticateWithRedirect, reload as _reload, revokeAccessToken as _revokeAccessToken, sendEmailVerification as _sendEmailVerification, sendPasswordResetEmail as _sendPasswordResetEmail, sendSignInLinkToEmail as _sendSignInLinkToEmail, setPersistence as _setPersistence, signInAnonymously as _signInAnonymously, signInWithCredential as _signInWithCredential, signInWithCustomToken as _signInWithCustomToken, signInWithEmailAndPassword as _signInWithEmailAndPassword, signInWithEmailLink as _signInWithEmailLink, signInWithPhoneNumber as _signInWithPhoneNumber, signInWithPopup as _signInWithPopup, signInWithRedirect as _signInWithRedirect, signOut as _signOut, unlink as _unlink, updateCurrentUser as _updateCurrentUser, updateEmail as _updateEmail, updatePassword as _updatePassword, updatePhoneNumber as _updatePhoneNumber, updateProfile as _updateProfile, useDeviceLanguage as _useDeviceLanguage, validatePassword as _validatePassword, verifyBeforeUpdateEmail as _verifyBeforeUpdateEmail, verifyPasswordResetCode as _verifyPasswordResetCode } from 'firebase/auth';
|
|
3
3
|
export declare const applyActionCode: typeof _applyActionCode;
|
|
4
4
|
export declare const beforeAuthStateChanged: typeof _beforeAuthStateChanged;
|
|
5
5
|
export declare const checkActionCode: typeof _checkActionCode;
|
|
@@ -30,6 +30,7 @@ export declare const reauthenticateWithPhoneNumber: typeof _reauthenticateWithPh
|
|
|
30
30
|
export declare const reauthenticateWithPopup: typeof _reauthenticateWithPopup;
|
|
31
31
|
export declare const reauthenticateWithRedirect: typeof _reauthenticateWithRedirect;
|
|
32
32
|
export declare const reload: typeof _reload;
|
|
33
|
+
export declare const revokeAccessToken: typeof _revokeAccessToken;
|
|
33
34
|
export declare const sendEmailVerification: typeof _sendEmailVerification;
|
|
34
35
|
export declare const sendPasswordResetEmail: typeof _sendPasswordResetEmail;
|
|
35
36
|
export declare const sendSignInLinkToEmail: typeof _sendSignInLinkToEmail;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InjectionToken, Injector,
|
|
1
|
+
import { EnvironmentProviders, InjectionToken, Injector, NgZone } from '@angular/core';
|
|
2
2
|
import { FirebaseApp } from '@angular/fire/app';
|
|
3
3
|
import { Database as FirebaseDatabase } from 'firebase/database';
|
|
4
4
|
import { Database } from './database';
|
|
@@ -12,4 +12,4 @@ export declare class DatabaseModule {
|
|
|
12
12
|
static ɵmod: i0.ɵɵNgModuleDeclaration<DatabaseModule, never, never, never>;
|
|
13
13
|
static ɵinj: i0.ɵɵInjectorDeclaration<DatabaseModule>;
|
|
14
14
|
}
|
|
15
|
-
export declare function provideDatabase(fn: (injector: Injector) => FirebaseDatabase, ...deps: any[]):
|
|
15
|
+
export declare function provideDatabase(fn: (injector: Injector) => FirebaseDatabase, ...deps: any[]): EnvironmentProviders;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
`AngularFireAuth` promise proxies an initialized
|
|
6
6
|
`firebase.auth.Auth` instance, allowing you to log users in, out, etc. [See
|
|
7
|
-
the Firebase docs for more information on what methods are available.](https://firebase.google.com/docs/reference/js/
|
|
7
|
+
the Firebase docs for more information on what methods are available.](https://firebase.google.com/docs/reference/js/auth.auth)
|
|
8
8
|
|
|
9
9
|
> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).
|
|
10
10
|
|
|
@@ -65,7 +65,7 @@ import { SETTINGS as AUTH_SETTINGS } from '@angular/fire/compat/auth';
|
|
|
65
65
|
export class AppModule { }
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
Read more at [Firebase Auth Settings](https://firebase.google.com/docs/reference/js/
|
|
68
|
+
Read more at [Firebase Auth Settings](https://firebase.google.com/docs/reference/js/auth.authsettings).
|
|
69
69
|
|
|
70
70
|
### Use Current Browser Language
|
|
71
71
|
|
|
@@ -90,7 +90,7 @@ export class AppModule { }
|
|
|
90
90
|
If you want to set a different language, you can use `LANGUAGE_CODE` DI Token
|
|
91
91
|
(*default: null*).
|
|
92
92
|
|
|
93
|
-
More info at the [firebase auth docs](https://firebase.google.com/docs/reference/js/
|
|
93
|
+
More info at the [firebase auth docs](https://firebase.google.com/docs/reference/js/auth.auth#authlanguagecode).
|
|
94
94
|
|
|
95
95
|
```ts
|
|
96
96
|
import { LANGUAGE_CODE } from '@angular/fire/compat/auth';
|
|
@@ -150,7 +150,7 @@ export class AppModule { }
|
|
|
150
150
|
```
|
|
151
151
|
|
|
152
152
|
- [Multi-Tenancy Authentication](https://cloud.google.com/identity-platform/docs/multi-tenancy-authentication)
|
|
153
|
-
- [Firebase Auth Tenant](https://firebase.google.com/docs/reference/js/
|
|
153
|
+
- [Firebase Auth Tenant](https://firebase.google.com/docs/reference/js/auth.auth#tenantid)
|
|
154
154
|
|
|
155
155
|
## UI Libraries
|
|
156
156
|
|
|
@@ -60,6 +60,21 @@ Follow the instructions to download whatever emulator you want to use then check
|
|
|
60
60
|
}
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
+
Then launch the emulators by running
|
|
64
|
+
|
|
65
|
+
```shell
|
|
66
|
+
firebase emulators:start
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Then you can visit
|
|
70
|
+
|
|
71
|
+
```shell
|
|
72
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
73
|
+
│ ✔ All emulators ready! It is now safe to connect your app. │
|
|
74
|
+
│ i View Emulator UI at http://127.0.0.1:4000/ │
|
|
75
|
+
└─────────────────────────────────────────────────────────────┘
|
|
76
|
+
```
|
|
77
|
+
|
|
63
78
|
## Import the DI Tokens at your AppModule
|
|
64
79
|
|
|
65
80
|
Configuring your app to connect to local emulators is easily done by using dependency injection tokens provided by the library. However, there are slighty changes between 6.0.0 and 6.1.0 in the way it was done.
|
|
@@ -68,6 +83,17 @@ Configuring your app to connect to local emulators is easily done by using depen
|
|
|
68
83
|
|
|
69
84
|
Each module (database, firestore, auth, function) provides `USE_EMULATOR` token to configure the emulator `host` and `port` by passing a tuple of `[string, number]` values, which are set by default to `localhost` and the asigned port from your `firebase.json` file.
|
|
70
85
|
|
|
86
|
+
Update your `environment.ts` file:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
export const environment = {
|
|
90
|
+
production: false,
|
|
91
|
+
useEmulators: true,
|
|
92
|
+
...
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
|
|
71
97
|
Import these tokens at your `app.module.ts` as follow:
|
|
72
98
|
|
|
73
99
|
```ts
|
|
@@ -80,7 +106,7 @@ import { USE_EMULATOR as USE_FUNCTIONS_EMULATOR } from '@angular/fire/compat/fun
|
|
|
80
106
|
// ... Existing configuration
|
|
81
107
|
providers: [
|
|
82
108
|
// ... Existing Providers
|
|
83
|
-
{ provide: USE_AUTH_EMULATOR, useValue: environment.useEmulators ? ['localhost', 9099] : undefined },
|
|
109
|
+
{ provide: USE_AUTH_EMULATOR, useValue: environment.useEmulators ? ['http://localhost', 9099] : undefined },
|
|
84
110
|
{ provide: USE_DATABASE_EMULATOR, useValue: environment.useEmulators ? ['localhost', 9000] : undefined },
|
|
85
111
|
{ provide: USE_FIRESTORE_EMULATOR, useValue: environment.useEmulators ? ['localhost', 8080] : undefined },
|
|
86
112
|
{ provide: USE_FUNCTIONS_EMULATOR, useValue: environment.useEmulators ? ['localhost', 5001] : undefined },
|
|
@@ -131,4 +157,4 @@ import { SETTINGS as FIRESTORE_SETTINGS } from '@angular/fire/compat/firestore';
|
|
|
131
157
|
export class AppModule { }
|
|
132
158
|
```
|
|
133
159
|
|
|
134
|
-
For older versions, please upgrade your app to latest version to get the advantages of these new features :rocket:
|
|
160
|
+
For older versions, please upgrade your app to latest version to get the advantages of these new features :rocket:
|
|
@@ -7,7 +7,7 @@ Each *document* contains a set of key-value pairs. Cloud Firestore is optimized
|
|
|
7
7
|
|
|
8
8
|
## Using `AngularFirestoreCollection`
|
|
9
9
|
|
|
10
|
-
The `AngularFirestoreCollection` service is a wrapper around the native Firestore SDK's [`CollectionReference`](https://firebase.google.com/docs/reference/js/firebase.firestore.CollectionReference) and [`Query`](https://firebase.google.com/docs/reference/js/firebase.firestore.Query) types. It is a generic service that provides you with a strongly typed set of methods for manipulating and streaming data. This service is designed for use as an `@Injectable()`.
|
|
10
|
+
The `AngularFirestoreCollection` service is a wrapper around the native Firestore SDK's [`CollectionReference`](https://firebase.google.com/docs/reference/js/v8/firebase.firestore.CollectionReference) and [`Query`](https://firebase.google.com/docs/reference/js/v8/firebase.firestore.Query) types. It is a generic service that provides you with a strongly typed set of methods for manipulating and streaming data. This service is designed for use as an `@Injectable()`.
|
|
11
11
|
|
|
12
12
|
```ts
|
|
13
13
|
import { Component } from '@angular/core';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# 4. Querying Collections in AngularFirestore
|
|
2
2
|
|
|
3
3
|
> Firestore has [powerful querying syntax](https://firebase.google.com/docs/firestore/query-data/queries) and the `AngularFirestoreCollection` provides a thin wrapper around it. This keeps you from having to learn two query syntax systems.
|
|
4
|
-
If you know the [Firestore query API](https://firebase.google.com/docs/reference/js/firebase.firestore.Query) then you know how to query in AngularFirestore.
|
|
4
|
+
If you know the [Firestore query API](https://firebase.google.com/docs/reference/js/v8/firebase.firestore.Query) then you know how to query in AngularFirestore.
|
|
5
5
|
|
|
6
6
|
> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).
|
|
7
7
|
|
|
8
8
|
## Creating a query with primitive/scalar values
|
|
9
9
|
|
|
10
|
-
Queries are created by building on the [`firebase.firestore.CollectionReference`](https://firebase.google.com/docs/reference/js/firebase.firestore.CollectionReference).
|
|
10
|
+
Queries are created by building on the [`firebase.firestore.CollectionReference`](https://firebase.google.com/docs/reference/js/v8/firebase.firestore.CollectionReference).
|
|
11
11
|
|
|
12
12
|
```ts
|
|
13
13
|
afs.collection('items', ref => ref.where('size', '==', 'large'))
|
package/docs/compat.md
CHANGED
|
@@ -38,7 +38,7 @@ Firebase offers two cloud-based, client-accessible database solutions that suppo
|
|
|
38
38
|
|
|
39
39
|
### Authenticate users
|
|
40
40
|
|
|
41
|
-
- [Getting started with Firebase Authentication](
|
|
41
|
+
- [Getting started with Firebase Authentication](compat/auth/getting-started.md)
|
|
42
42
|
- [Route users with AngularFire guards](compat/auth/router-guards.md)
|
|
43
43
|
|
|
44
44
|
### Local Emulator Suite
|
package/docs/messaging.md
CHANGED
|
@@ -6,20 +6,198 @@
|
|
|
6
6
|
|
|
7
7
|
# Cloud Messaging
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Firebase FCM allows you to register devices with unique FCM tokens, that you can later programtically send notifications to using Firebase Cloud Functions. It is up to the application to update these tokens in Firebase if you want to use them in other layers of your application, i.e send a notification to all administrators, etc. In that case, you would likely want to store your fcm tokens on your user collection, or a sub collection or another collection with different permissions.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
# Provide Messaging to your existing application
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
```
|
|
14
|
+
import { getMessaging, provideMessaging } from "@angular/fire/messaging";
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
bootstrapApplication(AppComponent, {
|
|
17
|
+
providers: [
|
|
18
|
+
...,
|
|
19
|
+
provideMessaging(() => getMessaging())
|
|
20
|
+
),
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
```
|
|
16
24
|
|
|
17
|
-
|
|
25
|
+
# Create a Firebase Messaging Service Worker
|
|
18
26
|
|
|
19
|
-
|
|
27
|
+
There are two parts to Firebase Messaging, a Service Worker and the DOM API. Angular Fire Messaging allows you to request permission, get tokens, delete tokens, and subscribe to messages on the DOM side. To register to receive notifications you need to set up the Service Worker. [The official Firebase documentation for setting up the details exactly how to do that](https://firebase.google.com/docs/cloud-messaging/js/client).
|
|
20
28
|
|
|
21
|
-
|
|
29
|
+
#### Create your firebase-messaging-sw.js file in your src/assets folder
|
|
22
30
|
|
|
23
|
-
|
|
31
|
+
*Note: When copying the below file, make sure your firebase version in your installation matches the version your are importing from below*
|
|
24
32
|
|
|
25
|
-
|
|
33
|
+
It may be wise to use file replacements or environments here for different environments
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
// This sample application is using 9.22, make sure you are importing the same version
|
|
37
|
+
|
|
38
|
+
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-app.js";
|
|
39
|
+
import { getMessaging } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-messaging-sw.js";
|
|
40
|
+
|
|
41
|
+
const firebaseApp = initializeApp({
|
|
42
|
+
apiKey: "",
|
|
43
|
+
authDomain: "",
|
|
44
|
+
projectId: "",
|
|
45
|
+
storageBucket: "",
|
|
46
|
+
messagingSenderId: "",
|
|
47
|
+
appId: "",
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const messaging = getMessaging(firebaseApp);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
# Example messaging service
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
import { Injectable } from "@angular/core";
|
|
57
|
+
import { Messaging, getToken, onMessage, deleteToken } from "@angular/fire/messaging";
|
|
58
|
+
import { Observable, tap } from "rxjs";
|
|
59
|
+
|
|
60
|
+
@Injectable({
|
|
61
|
+
providedIn: "root",
|
|
62
|
+
})
|
|
63
|
+
export class FcmService {
|
|
64
|
+
constructor(private msg: Messaging){
|
|
65
|
+
Notification.requestPermission().then(
|
|
66
|
+
(notificationPermissions: NotificationPermission) => {
|
|
67
|
+
if (notificationPermissions === "granted") {
|
|
68
|
+
console.log("Granted");
|
|
69
|
+
}
|
|
70
|
+
if (notificationPermissions === "denied") {
|
|
71
|
+
console.log("Denied");
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
navigator.serviceWorker
|
|
75
|
+
.register("/assets/firebase-messaging-sw.js", {
|
|
76
|
+
type: "module",
|
|
77
|
+
})
|
|
78
|
+
.then((serviceWorkerRegistration) => {
|
|
79
|
+
getToken(this.msg, {
|
|
80
|
+
vapidKey: `an optional key generated on Firebase for your fcm tokens`,
|
|
81
|
+
serviceWorkerRegistration: serviceWorkerRegistration,
|
|
82
|
+
}).then((x) => {
|
|
83
|
+
console.log('my fcm token', x);
|
|
84
|
+
// This is a good place to then store it on your database for each user
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
this.message$ = new Observable((sub) => onMessage(this.msg, (msg) =>
|
|
89
|
+
sub.next(msg))).pipe(
|
|
90
|
+
tap((msg) => {
|
|
91
|
+
console.log("My Firebase Cloud Message", msg);
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
deleteToken(){
|
|
96
|
+
// We can also delete fcm tokens, make sure to also update this on your firestore db if you are storing them as well
|
|
97
|
+
await deleteToken(this.msg);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
# Testing and Sending Notifications
|
|
102
|
+
|
|
103
|
+
Firebase will allow you to send a test notification under Engage > Messaging > New Campaign > Notifications. Here you can click send a test message. Additionally, you can send them programmatically through Firebase cloud functions.
|
|
104
|
+
|
|
105
|
+
Here is a barebones Node example:
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
export const sendTestMessage = onRequest(async (_, res) => {
|
|
109
|
+
try {
|
|
110
|
+
const message = {
|
|
111
|
+
notification: {
|
|
112
|
+
title: "Test Title",
|
|
113
|
+
body: "Test Body",
|
|
114
|
+
},
|
|
115
|
+
token: "your token here, you can store these and retreive as you please",
|
|
116
|
+
};
|
|
117
|
+
await admin.messaging().send(message);
|
|
118
|
+
res.sendStatus(200);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error(error);
|
|
121
|
+
res.sendStatus(500);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Here is a Node example that listens for a new comment on a collection, then sends a notification, and also adds it to a cache on Firebase so users can click through them.
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
exports.onPostReply =
|
|
130
|
+
onDocumentCreated("comments/{commentId}", async (event) => {
|
|
131
|
+
if (!event) throw new Error("No event found for document creation");
|
|
132
|
+
const snapshot = event.data;
|
|
133
|
+
if (!snapshot) {
|
|
134
|
+
throw new Error("No data associated with the event");
|
|
135
|
+
}
|
|
136
|
+
const data = snapshot.data();
|
|
137
|
+
if (!data.postId) {
|
|
138
|
+
throw new Error("No post ID found");
|
|
139
|
+
}
|
|
140
|
+
const postRef = await firestore.collection("posts").doc(data.postId).get();
|
|
141
|
+
const postData = postRef.data();
|
|
142
|
+
if (!postData) {
|
|
143
|
+
throw new Error("No postData found");
|
|
144
|
+
}
|
|
145
|
+
// userUid will be the post author's id.
|
|
146
|
+
const {userUid} = postData;
|
|
147
|
+
if (!userUid) {
|
|
148
|
+
throw new Error(
|
|
149
|
+
"Could not find the userUid for the post author for post reply"
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
const messageForNotification = {
|
|
153
|
+
title: "You have a new reply on your post",
|
|
154
|
+
body: "",
|
|
155
|
+
};
|
|
156
|
+
await createNotificationAndCache(messageForNotification, userUid);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// If you want to cache notifications a number of times, abstracting this
|
|
160
|
+
// to a function can bring a lot of value.
|
|
161
|
+
|
|
162
|
+
interface NotificationProps {
|
|
163
|
+
title: string;
|
|
164
|
+
body: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async function createNotificationAndCache(
|
|
168
|
+
notificationProps: NotificationProps, userAuthUid: string) {
|
|
169
|
+
const userRef = await firestore.collection("users").where("authUid", "==",
|
|
170
|
+
userAuthUid).get();
|
|
171
|
+
const userData = userRef.docs[0].data();
|
|
172
|
+
|
|
173
|
+
const promises: Promise<any>[] = [];
|
|
174
|
+
// This sample application has seperate fcm tokens for web and mobile
|
|
175
|
+
if (userData.mobileToken) {
|
|
176
|
+
const message = {
|
|
177
|
+
notification: notificationProps,
|
|
178
|
+
token: userData.mobileToken,
|
|
179
|
+
};
|
|
180
|
+
const promise = admin.messaging().send(message);
|
|
181
|
+
promises.push(promise);
|
|
182
|
+
}
|
|
183
|
+
if (userData.webToken) {
|
|
184
|
+
const message = {
|
|
185
|
+
notification: notificationProps,
|
|
186
|
+
token: userData.webToken,
|
|
187
|
+
};
|
|
188
|
+
const promise = admin.messaging().send(message);
|
|
189
|
+
promises.push(promise);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const notificationCacheValue = {
|
|
193
|
+
userAuthUid: userAuthUid,
|
|
194
|
+
tokenTitle: notificationProps.title,
|
|
195
|
+
tokenBody: notificationProps.body,
|
|
196
|
+
isActive: true, // This determines whether a notification has been seen
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
promises.push(
|
|
200
|
+
firestore.collection("notificationCache").add(notificationCacheValue));
|
|
201
|
+
|
|
202
|
+
await Promise.all(promises);
|
|
203
|
+
} ```
|