@quintype/framework 7.3.2-node16.5 → 7.3.2-node16.6
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 +51 -27
- package/client/impl/fcm.js +0 -4
- package/client/start.js +3 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -145,23 +145,30 @@ startApp(renderApplication, CUSTOM_REDUCERS, {
|
|
|
145
145
|
|
|
146
146
|
Steps to Integrate FCM in your project
|
|
147
147
|
|
|
148
|
-
1. While executing startApp in your project
|
|
148
|
+
1. app/client/app.js While executing startApp in your project send the firebaseConfig via opts. `firebaseConfig` can either be an object or a function that returns the firebase config object
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
Example:
|
|
151
151
|
|
|
152
|
-
```
|
|
152
|
+
```js
|
|
153
153
|
startApp(renderApplication,
|
|
154
154
|
CUSTOM_REDUCERS,
|
|
155
155
|
{
|
|
156
156
|
enableServiceWorker: process.env.NODE_ENV === "production",
|
|
157
|
-
|
|
157
|
+
firebaseConfig: {
|
|
158
|
+
messagingSenderId: --YOUR KEY-- ,
|
|
159
|
+
projectId: --YOUR KEY--,
|
|
160
|
+
apiKey: --YOUR KEY--,
|
|
161
|
+
storageBucket: --YOUR KEY--,
|
|
162
|
+
authDomain: --YOUR KEY--,
|
|
163
|
+
appId: --YOUR KEY--,
|
|
164
|
+
}
|
|
158
165
|
...
|
|
159
166
|
})
|
|
160
167
|
```
|
|
161
168
|
|
|
162
169
|
2. app/server/app.js should have the fcm configuration as below:
|
|
163
170
|
|
|
164
|
-
```
|
|
171
|
+
```js
|
|
165
172
|
isomorphicRoutes(app, {
|
|
166
173
|
...
|
|
167
174
|
fcmServerKey: (config) => <ServerKey> || fcmServerKey: <ServerKey> {(function|string)}
|
|
@@ -174,28 +181,45 @@ isomorphicRoutes(app, {
|
|
|
174
181
|
|
|
175
182
|
Example of the script:
|
|
176
183
|
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
184
|
+
```js
|
|
185
|
+
importScripts("https://www.gstatic.com/firebasejs/9.6.10/firebase-app-compat.js");
|
|
186
|
+
importScripts("https://www.gstatic.com/firebasejs/9.6.10/firebase-messaging-compat.js");
|
|
187
|
+
|
|
188
|
+
firebase.initializeApp({
|
|
189
|
+
messagingSenderId: --YOUR KEY-- ,
|
|
190
|
+
projectId: --YOUR KEY--,
|
|
191
|
+
apiKey: --YOUR KEY--,
|
|
192
|
+
storageBucket: --YOUR KEY--,
|
|
193
|
+
authDomain: --YOUR KEY--,
|
|
194
|
+
appId: --YOUR KEY--,
|
|
195
|
+
});
|
|
196
|
+
self.addEventListener('notificationclick', (event) => {
|
|
197
|
+
|
|
198
|
+
const url = event.notification.data.url;
|
|
199
|
+
if(url) {
|
|
200
|
+
clients.openWindow(url);
|
|
201
|
+
}
|
|
202
|
+
clients.openWindow(-- YOUR Sketches Host --);
|
|
203
|
+
}, false);
|
|
204
|
+
|
|
205
|
+
const messaging = firebase.messaging();
|
|
206
|
+
|
|
207
|
+
messaging.onBackgroundMessage(function(payload) {
|
|
208
|
+
const data = payload["data"];
|
|
209
|
+
const notificationTitle = data.title || ""
|
|
210
|
+
const notificationOptions = {
|
|
211
|
+
body: data.body,
|
|
212
|
+
icon: data["hero_image_s3_url"],
|
|
213
|
+
image: data["hero_image_s3_url"],
|
|
214
|
+
data: {
|
|
215
|
+
url: data["click_action"],
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
self.registration.showNotification(notificationTitle,
|
|
220
|
+
notificationOptions);
|
|
221
|
+
});
|
|
222
|
+
|
|
199
223
|
```
|
|
200
224
|
|
|
201
225
|
4. Make sure that the page data should have config with key fcmMessageSenderId refer doStartApp function in app/client/start.js.
|
package/client/impl/fcm.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export function initializeFCM(firebaseConfig) {
|
|
2
|
-
if (!firebaseConfig.messagingSenderId) {
|
|
3
|
-
console.log("messagingSenderId is required");
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
2
|
Promise.all([
|
|
7
3
|
import(/* webpackChunkName: "firebase-app" */ "firebase/app"),
|
|
8
4
|
import(/* webpackChunkName: "firebase-messaging" */ "firebase/messaging"),
|
package/client/start.js
CHANGED
|
@@ -286,7 +286,9 @@ export function startApp(renderApplication, reducers, opts) {
|
|
|
286
286
|
const fcm = typeof opts.firebaseConfig === "function" ? opts.firebaseConfig(page) : opts.firebaseConfig;
|
|
287
287
|
if (fcm) {
|
|
288
288
|
const mssgSenderId = fcm.messagingSenderId;
|
|
289
|
-
|
|
289
|
+
const projectId = fcm.projectId;
|
|
290
|
+
const apiKey = fcm.apiKey;
|
|
291
|
+
if (mssgSenderId && projectId && apiKey) initializeFCM(fcm);
|
|
290
292
|
}
|
|
291
293
|
}
|
|
292
294
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quintype/framework",
|
|
3
|
-
"version": "7.3.2-node16.
|
|
3
|
+
"version": "7.3.2-node16.6",
|
|
4
4
|
"description": "Libraries to help build Quintype Node.js apps",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"homepage": "https://github.com/quintype/quintype-node-framework#readme",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@ampproject/toolbox-optimizer": "2.8.3",
|
|
30
|
-
"@quintype/amp": "^2.4.
|
|
30
|
+
"@quintype/amp": "^2.4.20-amp-date-translation.1",
|
|
31
31
|
"@quintype/backend": "^2.3.1",
|
|
32
32
|
"@quintype/components": "^3.0.0",
|
|
33
33
|
"@quintype/prerender-node": "^3.2.24",
|