@parse/push-adapter 6.4.1 → 6.5.0

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.
Files changed (3) hide show
  1. package/README.md +19 -0
  2. package/package.json +2 -2
  3. package/src/FCM.js +13 -1
package/README.md CHANGED
@@ -19,8 +19,10 @@ The official Push Notification adapter for Parse Server. See [Parse Server Push
19
19
  - [Configure Parse Server](#configure-parse-server)
20
20
  - [Apple Push Options](#apple-push-options)
21
21
  - [Android Push Options](#android-push-options)
22
+ - [Firebase Cloud Messaging (FCM)](#firebase-cloud-messaging-fcm)
22
23
  - [Google Cloud Service Account Key](#google-cloud-service-account-key)
23
24
  - [Migration to FCM HTTP v1 API (June 2024)](#migration-to-fcm-http-v1-api-june-2024)
25
+ - [HTTP/1.1 Legacy Option](#http11-legacy-option)
24
26
  - [Expo Push Options](#expo-push-options)
25
27
  - [Bundled with Parse Server](#bundled-with-parse-server)
26
28
  - [Logging](#logging)
@@ -110,6 +112,10 @@ android: {
110
112
  }
111
113
  ```
112
114
 
115
+ ### Firebase Cloud Messaging (FCM)
116
+
117
+ This section contains some considerations when using FCM, regardless of the destination ecosystems the push notification is sent to.
118
+
113
119
  #### Google Cloud Service Account Key
114
120
 
115
121
  The Firebase console allows to easily create and download a Google Cloud service account key JSON file with the required permissions. Instead of setting `firebaseServiceAccount` to the path of the JSON file, you can provide an object representing a Google Cloud service account key:
@@ -139,6 +145,19 @@ android: {
139
145
  }
140
146
  ```
141
147
 
148
+ #### HTTP/1.1 Legacy Option
149
+
150
+ With the introduction of the FCM HTTP v1 API, support for HTTP/2 was added which provides faster throughput for push notifications. To use the older version HTTP/1.1 set `fcmEnableLegacyHttpTransport: true` in your push options.
151
+
152
+ Example options:
153
+
154
+ ```js
155
+ android: {
156
+ firebaseServiceAccount: __dirname + '/firebase.json',
157
+ fcmEnableLegacyHttpTransport: true
158
+ }
159
+ ```
160
+
142
161
  ### Expo Push Options
143
162
 
144
163
  Example options:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parse/push-adapter",
3
- "version": "6.4.1",
3
+ "version": "6.5.0",
4
4
  "description": "Base parse-server-push-adapter",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "@parse/node-apn": "6.0.1",
28
28
  "@parse/node-gcm": "1.0.2",
29
29
  "expo-server-sdk": "3.10.0",
30
- "firebase-admin": "12.1.1",
30
+ "firebase-admin": "12.3.0",
31
31
  "npmlog": "7.0.1",
32
32
  "parse": "5.2.0",
33
33
  "web-push": "3.6.7"
package/src/FCM.js CHANGED
@@ -25,14 +25,26 @@ export default function FCM(args, pushType) {
25
25
  );
26
26
  }
27
27
 
28
+ const fcmEnableLegacyHttpTransport = typeof args.fcmEnableLegacyHttpTransport === 'boolean'
29
+ ? args.fcmEnableLegacyHttpTransport
30
+ : false;
31
+
28
32
  let app;
29
33
  if (getApps().length === 0) {
30
34
  app = initializeApp({ credential: cert(args.firebaseServiceAccount) });
31
35
  } else {
32
36
  app = getApp();
33
37
  }
38
+
34
39
  this.sender = getMessaging(app);
35
- this.pushType = pushType; // Push type is only used to remain backwards compatible with APNS and GCM
40
+
41
+ if (fcmEnableLegacyHttpTransport) {
42
+ this.sender.enableLegacyHttpTransport();
43
+ log.warn(LOG_PREFIX, 'Legacy HTTP/1.1 transport is enabled. This is a deprecated feature and support for this flag will be removed in the future.');
44
+ }
45
+
46
+ // Push type is only used to remain backwards compatible with APNS and GCM
47
+ this.pushType = pushType;
36
48
  }
37
49
 
38
50
  FCM.FCMRegistrationTokensMax = FCMRegistrationTokensMax;