@angular/fire 17.0.1 → 17.1.0-canary.58e6c3b
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 +30 -23
- package/analytics/analytics.module.d.ts +2 -2
- package/app/app.module.d.ts +2 -2
- package/app/firebase.d.ts +2 -1
- package/app-check/app-check.module.d.ts +2 -2
- package/auth/auth.module.d.ts +2 -2
- package/database/database.module.d.ts +2 -2
- package/docs/analytics.md +17 -29
- package/docs/app-check.md +17 -13
- package/docs/auth.md +44 -9
- 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/database.md +13 -13
- package/docs/firestore.md +23 -24
- package/docs/functions.md +15 -12
- package/docs/install-and-setup.md +1 -1
- package/docs/messaging.md +210 -10
- package/docs/performance.md +14 -16
- package/docs/remote-config.md +14 -12
- package/docs/storage.md +12 -11
- package/docs/vertexai.md +53 -0
- package/esm2022/analytics/analytics.module.mjs +24 -17
- package/esm2022/app/app.module.mjs +22 -16
- package/esm2022/app/firebase.mjs +3 -2
- package/esm2022/app-check/app-check.module.mjs +20 -18
- package/esm2022/auth/auth.module.mjs +20 -18
- package/esm2022/database/database.module.mjs +22 -20
- package/esm2022/firestore/firestore.module.mjs +22 -20
- package/esm2022/firestore/lite/lite.module.mjs +22 -20
- package/esm2022/functions/functions.module.mjs +22 -20
- package/esm2022/messaging/messaging.module.mjs +24 -17
- package/esm2022/performance/performance.module.mjs +20 -18
- package/esm2022/remote-config/remote-config.module.mjs +24 -17
- package/esm2022/storage/storage.module.mjs +22 -20
- package/esm2022/vertexai-preview/angular-fire-vertexai-preview.mjs +5 -0
- package/esm2022/vertexai-preview/firebase.mjs +7 -0
- package/esm2022/vertexai-preview/public_api.mjs +4 -0
- package/esm2022/vertexai-preview/vertexai.mjs +16 -0
- package/esm2022/vertexai-preview/vertexai.module.mjs +73 -0
- package/fesm2022/angular-fire-analytics.mjs +23 -16
- package/fesm2022/angular-fire-analytics.mjs.map +1 -1
- package/fesm2022/angular-fire-app-check.mjs +19 -17
- package/fesm2022/angular-fire-app-check.mjs.map +1 -1
- package/fesm2022/angular-fire-app.mjs +24 -17
- package/fesm2022/angular-fire-app.mjs.map +1 -1
- package/fesm2022/angular-fire-auth.mjs +19 -17
- package/fesm2022/angular-fire-auth.mjs.map +1 -1
- package/fesm2022/angular-fire-database.mjs +21 -19
- package/fesm2022/angular-fire-database.mjs.map +1 -1
- package/fesm2022/angular-fire-firestore-lite.mjs +21 -19
- package/fesm2022/angular-fire-firestore-lite.mjs.map +1 -1
- package/fesm2022/angular-fire-firestore.mjs +21 -19
- package/fesm2022/angular-fire-firestore.mjs.map +1 -1
- package/fesm2022/angular-fire-functions.mjs +21 -19
- package/fesm2022/angular-fire-functions.mjs.map +1 -1
- package/fesm2022/angular-fire-messaging.mjs +23 -16
- package/fesm2022/angular-fire-messaging.mjs.map +1 -1
- package/fesm2022/angular-fire-performance.mjs +19 -17
- package/fesm2022/angular-fire-performance.mjs.map +1 -1
- package/fesm2022/angular-fire-remote-config.mjs +23 -16
- package/fesm2022/angular-fire-remote-config.mjs.map +1 -1
- package/fesm2022/angular-fire-storage.mjs +21 -19
- package/fesm2022/angular-fire-storage.mjs.map +1 -1
- package/fesm2022/angular-fire-vertexai-preview.mjs +99 -0
- package/fesm2022/angular-fire-vertexai-preview.mjs.map +1 -0
- package/firestore/firestore.module.d.ts +2 -2
- package/firestore/lite/lite.module.d.ts +2 -2
- package/functions/functions.module.d.ts +2 -2
- package/messaging/messaging.module.d.ts +2 -2
- package/package.json +8 -2
- package/performance/performance.module.d.ts +2 -2
- package/remote-config/remote-config.module.d.ts +2 -2
- package/schematics/common.js +1 -26
- package/schematics/deploy/actions.js +7 -1
- package/schematics/interfaces.js +11 -11
- package/schematics/setup/index.js +7 -97
- package/schematics/setup/prompts.js +2 -91
- package/schematics/utils.js +27 -75
- package/storage/storage.module.d.ts +2 -2
- package/vertexai-preview/firebase.d.ts +4 -0
- package/vertexai-preview/index.d.ts +5 -0
- package/vertexai-preview/package.json +3 -0
- package/vertexai-preview/public_api.d.ts +3 -0
- package/vertexai-preview/vertexai.d.ts +13 -0
- package/vertexai-preview/vertexai.module.d.ts +15 -0
package/docs/firestore.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<img align="right" width="30%" src="images/firestore-illo_1x.png">
|
|
2
2
|
|
|
3
3
|
<small>
|
|
4
|
-
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Cloud Firestore
|
|
5
5
|
</small>
|
|
6
6
|
|
|
7
7
|
# Cloud Firestore
|
|
@@ -18,47 +18,45 @@ As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
|
18
18
|
```bash
|
|
19
19
|
ng add @angular/fire
|
|
20
20
|
```
|
|
21
|
-
Provide a Firestore instance in the application's `
|
|
21
|
+
Provide a Firestore instance in the application's `app.config.ts`:
|
|
22
22
|
|
|
23
|
-
```
|
|
24
|
-
@
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
```ts
|
|
24
|
+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
25
|
+
import { provideFirestore, getFirestore } from '@angular/fire/firestore';
|
|
26
|
+
|
|
27
|
+
export const appConfig: ApplicationConfig = {
|
|
28
|
+
providers: [
|
|
29
|
+
provideFirebaseApp(() => initializeApp({ ... })),
|
|
30
|
+
provideFirestore(() => getFirestore()),
|
|
29
31
|
...
|
|
30
|
-
// App initialization
|
|
31
|
-
provideFirebaseApp(() => initializeApp(environment.firebase)),
|
|
32
|
-
provideFirestore(() => getFirestore())
|
|
33
32
|
],
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
export class AppModule { }
|
|
33
|
+
...
|
|
34
|
+
}
|
|
38
35
|
```
|
|
39
36
|
|
|
40
|
-
|
|
41
|
-
In your component class, for example `user-profile.component.ts` import and inject `Firestore`:
|
|
37
|
+
Next inject `Firestore` into your component:
|
|
42
38
|
|
|
43
39
|
```typescript
|
|
44
40
|
import { Component, inject } from '@angular/core';
|
|
45
41
|
import { Firestore } from '@angular/fire/firestore';
|
|
46
42
|
|
|
47
|
-
@Component({
|
|
48
|
-
standalone: true,
|
|
49
|
-
selector: 'app-user-profile',
|
|
50
|
-
...
|
|
51
|
-
})
|
|
43
|
+
@Component({ ... })
|
|
52
44
|
export class UserProfileComponent {
|
|
53
|
-
private firestore
|
|
45
|
+
private firestore = inject(Firestore);
|
|
54
46
|
...
|
|
55
47
|
}
|
|
56
48
|
```
|
|
57
49
|
|
|
58
50
|
## Firebase API
|
|
59
|
-
|
|
51
|
+
|
|
52
|
+
AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
|
|
53
|
+
|
|
54
|
+
Update the imports from `import { ... } from 'firebase/firestore'` to `import { ... } from '@angular/fire/firestore'` and follow the official documentation.
|
|
55
|
+
|
|
56
|
+
[Getting Started](https://firebase.google.com/docs/firestore/quickstart#web-modular-api) | [API Reference](https://firebase.google.com/docs/reference/js/firestore)
|
|
60
57
|
|
|
61
58
|
### Reading data
|
|
59
|
+
|
|
62
60
|
In Cloud Firestore data is stored in `documents` and `documents` are stored in `collections`. The path to data follows `<collection_name>/<document_id>` and continues if there are subcollections. For example, `"users/ABC12345/posts/XYZ6789"` represents:
|
|
63
61
|
* `users` collection
|
|
64
62
|
* document id `ABC12345`
|
|
@@ -111,6 +109,7 @@ export Interface UserProfile {
|
|
|
111
109
|
The `async` pipe handles unsubscribing from observables.
|
|
112
110
|
|
|
113
111
|
### Writing data
|
|
112
|
+
|
|
114
113
|
To write to Cloud Firestore use the `addDoc` function. It will create a new document at the path specified by the collection. In `user-profile.component.ts`, we'll update the code to add a new document on a `<button>` click.
|
|
115
114
|
|
|
116
115
|
|
package/docs/functions.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<img align="right" width="30%" src="images/functions-illo_1x.png">
|
|
2
2
|
|
|
3
3
|
<small>
|
|
4
|
-
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Cloud Functions
|
|
5
5
|
</small>
|
|
6
6
|
|
|
7
7
|
# Cloud Functions
|
|
@@ -17,21 +17,23 @@ As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
|
17
17
|
ng add @angular/fire
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Provide a Cloud Functions instance in the application's `
|
|
20
|
+
Provide a Cloud Functions instance in the application's `app.config.ts`:
|
|
21
21
|
|
|
22
22
|
```ts
|
|
23
23
|
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
24
|
-
import {
|
|
24
|
+
import { provideFunctions, getFunctions } from '@angular/fire/functions';
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
provideFirebaseApp(() => initializeApp(
|
|
26
|
+
export const appConfig: ApplicationConfig = {
|
|
27
|
+
providers: [
|
|
28
|
+
provideFirebaseApp(() => initializeApp({ ... })),
|
|
29
29
|
provideFunctions(() => getFunctions()),
|
|
30
|
-
|
|
30
|
+
...
|
|
31
|
+
],
|
|
32
|
+
...
|
|
31
33
|
})
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
Next inject
|
|
36
|
+
Next inject `Functions` into your component:
|
|
35
37
|
|
|
36
38
|
```ts
|
|
37
39
|
import { Component, inject} from '@angular/core';
|
|
@@ -39,14 +41,15 @@ import { Functions } from '@angular/fire/functions';
|
|
|
39
41
|
|
|
40
42
|
@Component({ ... })
|
|
41
43
|
export class AppComponent {
|
|
42
|
-
private functions
|
|
44
|
+
private functions = inject(Functions);
|
|
43
45
|
...
|
|
44
46
|
}
|
|
45
47
|
```
|
|
46
48
|
|
|
47
49
|
## Firebase API
|
|
48
|
-
The [Firebase API for Cloud Functions documentation](https://firebase.google.com/docs/reference/js/functions) is available on the Firebase website.
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
|
|
52
|
+
|
|
53
|
+
Update the imports from `import { ... } from 'firebase/functions'` to `import { ... } from '@angular/fire/functions'` and follow the official documentation.
|
|
51
54
|
|
|
52
|
-
|
|
55
|
+
[Call functions from your app](https://firebase.google.com/docs/functions/callable?gen=2nd#web-modular-api) | [API Reference](https://firebase.google.com/docs/reference/js/functions)
|
package/docs/messaging.md
CHANGED
|
@@ -1,25 +1,225 @@
|
|
|
1
1
|
<img align="right" width="30%" src="images/cloud-messaging-illo_1x.png">
|
|
2
2
|
|
|
3
3
|
<small>
|
|
4
|
-
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Cloud Messaging
|
|
5
5
|
</small>
|
|
6
6
|
|
|
7
7
|
# Cloud Messaging
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
[Learn More](https://firebase.google.com/docs/cloud-messaging/)
|
|
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.
|
|
12
10
|
|
|
13
11
|
## Dependency Injection
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
14
|
+
```bash
|
|
15
|
+
ng add @angular/fire
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Provide a Cloud Messaging instance in the application's `app.config.ts`:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
22
|
+
import { provideMessaging, getMessaging } from '@angular/fire/messaging';
|
|
23
|
+
|
|
24
|
+
export const appConfig: ApplicationConfig = {
|
|
25
|
+
providers: [
|
|
26
|
+
provideFirebaseApp(() => initializeApp({ ... })),
|
|
27
|
+
provideMessaging(() => getMessaging()),
|
|
28
|
+
...
|
|
29
|
+
],
|
|
30
|
+
...
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Next inject `Messaging` into your component:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { Component, inject} from '@angular/core';
|
|
38
|
+
import { Messaging } from '@angular/fire/messaging';
|
|
39
|
+
|
|
40
|
+
@Component({ ... })
|
|
41
|
+
export class AppComponent {
|
|
42
|
+
private messaging = inject(Messaging);
|
|
43
|
+
...
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
# Create a Firebase Messaging Service Worker
|
|
48
|
+
|
|
49
|
+
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).
|
|
50
|
+
|
|
51
|
+
#### Create your firebase-messaging-sw.js file in your src/assets folder
|
|
52
|
+
|
|
53
|
+
*Note: When copying the below file, make sure your firebase version in your installation matches the version your are importing from below*
|
|
54
|
+
|
|
55
|
+
It may be wise to use file replacements or environments here for different environments
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
// This sample application is using 9.22, make sure you are importing the same version
|
|
59
|
+
|
|
60
|
+
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-app.js";
|
|
61
|
+
import { getMessaging } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-messaging-sw.js";
|
|
62
|
+
|
|
63
|
+
const firebaseApp = initializeApp({
|
|
64
|
+
apiKey: "",
|
|
65
|
+
authDomain: "",
|
|
66
|
+
projectId: "",
|
|
67
|
+
storageBucket: "",
|
|
68
|
+
messagingSenderId: "",
|
|
69
|
+
appId: "",
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const messaging = getMessaging(firebaseApp);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
# Example messaging service
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
import { Injectable } from "@angular/core";
|
|
79
|
+
import { Messaging, getToken, onMessage, deleteToken } from "@angular/fire/messaging";
|
|
80
|
+
import { Observable, tap } from "rxjs";
|
|
81
|
+
|
|
82
|
+
@Injectable({
|
|
83
|
+
providedIn: "root",
|
|
84
|
+
})
|
|
85
|
+
export class FcmService {
|
|
86
|
+
constructor(private msg: Messaging){
|
|
87
|
+
Notification.requestPermission().then(
|
|
88
|
+
(notificationPermissions: NotificationPermission) => {
|
|
89
|
+
if (notificationPermissions === "granted") {
|
|
90
|
+
console.log("Granted");
|
|
91
|
+
}
|
|
92
|
+
if (notificationPermissions === "denied") {
|
|
93
|
+
console.log("Denied");
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
navigator.serviceWorker
|
|
97
|
+
.register("/assets/firebase-messaging-sw.js", {
|
|
98
|
+
type: "module",
|
|
99
|
+
})
|
|
100
|
+
.then((serviceWorkerRegistration) => {
|
|
101
|
+
getToken(this.msg, {
|
|
102
|
+
vapidKey: `an optional key generated on Firebase for your fcm tokens`,
|
|
103
|
+
serviceWorkerRegistration: serviceWorkerRegistration,
|
|
104
|
+
}).then((x) => {
|
|
105
|
+
console.log('my fcm token', x);
|
|
106
|
+
// This is a good place to then store it on your database for each user
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
this.message$ = new Observable((sub) => onMessage(this.msg, (msg) =>
|
|
111
|
+
sub.next(msg))).pipe(
|
|
112
|
+
tap((msg) => {
|
|
113
|
+
console.log("My Firebase Cloud Message", msg);
|
|
114
|
+
})
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
deleteToken(){
|
|
118
|
+
// We can also delete fcm tokens, make sure to also update this on your firestore db if you are storing them as well
|
|
119
|
+
await deleteToken(this.msg);
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
# Testing and Sending Notifications
|
|
124
|
+
|
|
125
|
+
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.
|
|
126
|
+
|
|
127
|
+
Here is a barebones Node example:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
export const sendTestMessage = onRequest(async (_, res) => {
|
|
131
|
+
try {
|
|
132
|
+
const message = {
|
|
133
|
+
notification: {
|
|
134
|
+
title: "Test Title",
|
|
135
|
+
body: "Test Body",
|
|
136
|
+
},
|
|
137
|
+
token: "your token here, you can store these and retreive as you please",
|
|
138
|
+
};
|
|
139
|
+
await admin.messaging().send(message);
|
|
140
|
+
res.sendStatus(200);
|
|
141
|
+
} catch (error) {
|
|
142
|
+
console.error(error);
|
|
143
|
+
res.sendStatus(500);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
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.
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
exports.onPostReply =
|
|
152
|
+
onDocumentCreated("comments/{commentId}", async (event) => {
|
|
153
|
+
if (!event) throw new Error("No event found for document creation");
|
|
154
|
+
const snapshot = event.data;
|
|
155
|
+
if (!snapshot) {
|
|
156
|
+
throw new Error("No data associated with the event");
|
|
157
|
+
}
|
|
158
|
+
const data = snapshot.data();
|
|
159
|
+
if (!data.postId) {
|
|
160
|
+
throw new Error("No post ID found");
|
|
161
|
+
}
|
|
162
|
+
const postRef = await firestore.collection("posts").doc(data.postId).get();
|
|
163
|
+
const postData = postRef.data();
|
|
164
|
+
if (!postData) {
|
|
165
|
+
throw new Error("No postData found");
|
|
166
|
+
}
|
|
167
|
+
// userUid will be the post author's id.
|
|
168
|
+
const {userUid} = postData;
|
|
169
|
+
if (!userUid) {
|
|
170
|
+
throw new Error(
|
|
171
|
+
"Could not find the userUid for the post author for post reply"
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
const messageForNotification = {
|
|
175
|
+
title: "You have a new reply on your post",
|
|
176
|
+
body: "",
|
|
177
|
+
};
|
|
178
|
+
await createNotificationAndCache(messageForNotification, userUid);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// If you want to cache notifications a number of times, abstracting this
|
|
182
|
+
// to a function can bring a lot of value.
|
|
183
|
+
|
|
184
|
+
interface NotificationProps {
|
|
185
|
+
title: string;
|
|
186
|
+
body: string;
|
|
187
|
+
}
|
|
16
188
|
|
|
17
|
-
|
|
189
|
+
async function createNotificationAndCache(
|
|
190
|
+
notificationProps: NotificationProps, userAuthUid: string) {
|
|
191
|
+
const userRef = await firestore.collection("users").where("authUid", "==",
|
|
192
|
+
userAuthUid).get();
|
|
193
|
+
const userData = userRef.docs[0].data();
|
|
18
194
|
|
|
19
|
-
|
|
195
|
+
const promises: Promise<any>[] = [];
|
|
196
|
+
// This sample application has seperate fcm tokens for web and mobile
|
|
197
|
+
if (userData.mobileToken) {
|
|
198
|
+
const message = {
|
|
199
|
+
notification: notificationProps,
|
|
200
|
+
token: userData.mobileToken,
|
|
201
|
+
};
|
|
202
|
+
const promise = admin.messaging().send(message);
|
|
203
|
+
promises.push(promise);
|
|
204
|
+
}
|
|
205
|
+
if (userData.webToken) {
|
|
206
|
+
const message = {
|
|
207
|
+
notification: notificationProps,
|
|
208
|
+
token: userData.webToken,
|
|
209
|
+
};
|
|
210
|
+
const promise = admin.messaging().send(message);
|
|
211
|
+
promises.push(promise);
|
|
212
|
+
}
|
|
20
213
|
|
|
21
|
-
|
|
214
|
+
const notificationCacheValue = {
|
|
215
|
+
userAuthUid: userAuthUid,
|
|
216
|
+
tokenTitle: notificationProps.title,
|
|
217
|
+
tokenBody: notificationProps.body,
|
|
218
|
+
isActive: true, // This determines whether a notification has been seen
|
|
219
|
+
};
|
|
22
220
|
|
|
23
|
-
|
|
221
|
+
promises.push(
|
|
222
|
+
firestore.collection("notificationCache").add(notificationCacheValue));
|
|
24
223
|
|
|
25
|
-
|
|
224
|
+
await Promise.all(promises);
|
|
225
|
+
} ```
|
package/docs/performance.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<img align="right" width="30%" src="images/performance-illo_1x.png">
|
|
2
2
|
|
|
3
3
|
<small>
|
|
4
|
-
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Performance Monitoring
|
|
5
5
|
</small>
|
|
6
6
|
|
|
7
7
|
# Performance Monitoring
|
|
@@ -17,21 +17,23 @@ As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
|
17
17
|
ng add @angular/fire
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Provide a Performance instance
|
|
20
|
+
Provide a Performance instance in the application's `app.config.ts`:
|
|
21
21
|
|
|
22
22
|
```ts
|
|
23
23
|
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
24
|
-
import {
|
|
24
|
+
import { providePerformance, getPerformance } from '@angular/fire/performance';
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
provideFirebaseApp(() => initializeApp(
|
|
26
|
+
export const appConfig: ApplicationConfig = {
|
|
27
|
+
providers: [
|
|
28
|
+
provideFirebaseApp(() => initializeApp({ ... })),
|
|
29
29
|
providePerformance(() => getPerformance()),
|
|
30
|
-
|
|
30
|
+
...
|
|
31
|
+
],
|
|
32
|
+
...
|
|
31
33
|
})
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
Next inject
|
|
36
|
+
Next inject `Performance` into your component:
|
|
35
37
|
|
|
36
38
|
```ts
|
|
37
39
|
import { Component, inject} from '@angular/core';
|
|
@@ -39,19 +41,15 @@ import { Performance } from '@angular/fire/performance';
|
|
|
39
41
|
|
|
40
42
|
@Component({ ... })
|
|
41
43
|
export class PerformanceComponent {
|
|
42
|
-
private performance
|
|
44
|
+
private performance = inject(Performance);
|
|
43
45
|
...
|
|
44
46
|
}
|
|
45
47
|
```
|
|
46
48
|
|
|
47
49
|
## Firebase API
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
## Services
|
|
52
|
-
|
|
53
|
-
Coming soon.
|
|
51
|
+
AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
|
|
54
52
|
|
|
55
|
-
|
|
53
|
+
Update the imports from `import { ... } from 'firebase/performance'` to `import { ... } from '@angular/fire/performance'` and follow the official documentation.
|
|
56
54
|
|
|
57
|
-
|
|
55
|
+
[Getting Started](https://firebase.google.com/docs/perf-mon/get-started-web) | [API Reference](https://firebase.google.com/docs/reference/js/performance)
|
package/docs/remote-config.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<img align="right" width="30%" src="images/remote-config-illo_1x.png">
|
|
2
2
|
|
|
3
3
|
<small>
|
|
4
|
-
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Remote Config
|
|
5
5
|
</small>
|
|
6
6
|
|
|
7
7
|
# Remote Config
|
|
@@ -17,21 +17,23 @@ As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
|
17
17
|
ng add @angular/fire
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Provide a
|
|
20
|
+
Provide a Remote Config instance in the application's `app.config.ts`:
|
|
21
21
|
|
|
22
22
|
```ts
|
|
23
23
|
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
24
|
-
import {
|
|
24
|
+
import { provideRemoteConfig, getRemoteConfig } from '@angular/fire/remote-config';
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
provideFirebaseApp(() => initializeApp(
|
|
26
|
+
export const appConfig: ApplicationConfig = {
|
|
27
|
+
providers: [
|
|
28
|
+
provideFirebaseApp(() => initializeApp({ ... })),
|
|
29
29
|
provideRemoteConfig(() => getRemoteConfig()),
|
|
30
|
-
|
|
30
|
+
...
|
|
31
|
+
],
|
|
32
|
+
...
|
|
31
33
|
})
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
Next inject
|
|
36
|
+
Next inject `RemoteConfig` into your component:
|
|
35
37
|
|
|
36
38
|
```ts
|
|
37
39
|
import { Component, inject} from '@angular/core';
|
|
@@ -39,15 +41,15 @@ import { RemoteConfig } from '@angular/fire/remote-config';
|
|
|
39
41
|
|
|
40
42
|
@Component({ ... })
|
|
41
43
|
export class RemoteConfigComponent {
|
|
42
|
-
private remoteConfig
|
|
44
|
+
private remoteConfig = inject(RemoteConfig);
|
|
43
45
|
...
|
|
44
46
|
}
|
|
45
47
|
```
|
|
46
48
|
|
|
47
49
|
## Firebase API
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
Update the imports from `import { ... } from 'firebase/remote-config'` to `import { ... } from '@angular/fire/remote-config'` and follow the official documentation.
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
[Getting Started](https://firebase.google.com/docs/remote-config/get-started?platform=web) | [API Reference](https://firebase.google.com/docs/reference/js/remote-config)
|
package/docs/storage.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<img align="right" width="30%" src="images/storage-illo_1x.png">
|
|
2
2
|
|
|
3
3
|
<small>
|
|
4
|
-
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Cloud Storage
|
|
5
5
|
</small>
|
|
6
6
|
|
|
7
7
|
# Cloud Storage
|
|
@@ -19,21 +19,23 @@ As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
|
19
19
|
ng add @angular/fire
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Provide a
|
|
22
|
+
Provide a Cloud Storage instance in the application's `app.config.ts`:
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
25
|
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
26
|
-
import {
|
|
26
|
+
import { provideStorage, getStorage } from '@angular/fire/storage';
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
provideFirebaseApp(() => initializeApp(
|
|
28
|
+
export const appConfig: ApplicationConfig = {
|
|
29
|
+
providers: [
|
|
30
|
+
provideFirebaseApp(() => initializeApp({ ... })),
|
|
31
31
|
provideStorage(() => getStorage()),
|
|
32
|
-
|
|
32
|
+
...
|
|
33
|
+
],
|
|
34
|
+
...
|
|
33
35
|
})
|
|
34
36
|
```
|
|
35
37
|
|
|
36
|
-
Next inject
|
|
38
|
+
Next inject `Storage` into your component:
|
|
37
39
|
|
|
38
40
|
```ts
|
|
39
41
|
import { Component, inject} from '@angular/core';
|
|
@@ -41,17 +43,16 @@ import { Storage } from '@angular/fire/storage';
|
|
|
41
43
|
|
|
42
44
|
@Component({ ... })
|
|
43
45
|
export class StorageComponent {
|
|
44
|
-
private storage
|
|
46
|
+
private storage = inject(Storage);
|
|
45
47
|
...
|
|
46
48
|
}
|
|
47
49
|
```
|
|
48
50
|
|
|
49
|
-
|
|
50
51
|
## Firebase API
|
|
51
52
|
|
|
52
53
|
AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
|
|
53
54
|
|
|
54
|
-
Update the imports from `import { ... } from 'firebase/storage'` to `import { ... } from '@angular/fire/storage'` and follow the
|
|
55
|
+
Update the imports from `import { ... } from 'firebase/storage'` to `import { ... } from '@angular/fire/storage'` and follow the official documentation.
|
|
55
56
|
|
|
56
57
|
[Getting Started](https://firebase.google.com/docs/storage/web/start) | [API Reference](https://firebase.google.com/docs/reference/js/storage)
|
|
57
58
|
|
package/docs/vertexai.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<small>
|
|
2
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Vertex AI
|
|
3
|
+
</small>
|
|
4
|
+
|
|
5
|
+
# Vertex AI (preview)
|
|
6
|
+
|
|
7
|
+
The Vertex AI Gemini API gives you access to the latest generative AI models from Google: the Gemini models.
|
|
8
|
+
|
|
9
|
+
[Learn more](https://firebase.google.com/docs/vertex-ai)
|
|
10
|
+
|
|
11
|
+
## Dependency Injection
|
|
12
|
+
|
|
13
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
14
|
+
```bash
|
|
15
|
+
ng add @angular/fire
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Provide a Vertex AI instance in the application's `app.config.ts`:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
22
|
+
import { provideVertexAI, getVertexAI } from '@angular/fire/vertexai-preview';
|
|
23
|
+
|
|
24
|
+
export const appConfig: ApplicationConfig = {
|
|
25
|
+
providers: [
|
|
26
|
+
provideFirebaseApp(() => initializeApp({ ... })),
|
|
27
|
+
provideVertexAI(() => getVertexAI()),
|
|
28
|
+
...
|
|
29
|
+
],
|
|
30
|
+
...,
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Next inject `VertexAI` into your component:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { Component, inject } from '@angular/core';
|
|
38
|
+
import { VertexAI } from '@angular/fire/vertexai-preview';
|
|
39
|
+
|
|
40
|
+
@Component({ ... })
|
|
41
|
+
export class MyComponent {
|
|
42
|
+
private vertexAI = inject(VertexAI);
|
|
43
|
+
...
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Firebase API
|
|
48
|
+
|
|
49
|
+
AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
|
|
50
|
+
|
|
51
|
+
Update the imports from `import { ... } from 'firebase/vertexai-preview'` to `import { ... } from '@angular/fire/vertexai-preview'` and follow the official documentation.
|
|
52
|
+
|
|
53
|
+
[Getting Started](https://firebase.google.com/docs/vertex-ai/get-started?platform=web) | [API Reference](https://firebase.google.com/docs/reference/js/vertexai-preview)
|