Skip to content

Commit 9ca14d4

Browse files
committed
change(fcm): Remove deprecated FCM APIs
1 parent ec1dc66 commit 9ca14d4

11 files changed

+103
-3609
lines changed

etc/firebase-admin.api.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -380,22 +380,12 @@ export namespace messaging {
380380
export type Message = Message;
381381
// Warning: (ae-forgotten-export) The symbol "Messaging" needs to be exported by the entry point default-namespace.d.ts
382382
export type Messaging = Messaging;
383-
// Warning: (ae-forgotten-export) The symbol "MessagingConditionResponse" needs to be exported by the entry point default-namespace.d.ts
384-
export type MessagingConditionResponse = MessagingConditionResponse;
385-
// Warning: (ae-forgotten-export) The symbol "MessagingDeviceGroupResponse" needs to be exported by the entry point default-namespace.d.ts
386-
export type MessagingDeviceGroupResponse = MessagingDeviceGroupResponse;
387-
// Warning: (ae-forgotten-export) The symbol "MessagingDeviceResult" needs to be exported by the entry point default-namespace.d.ts
388-
export type MessagingDeviceResult = MessagingDeviceResult;
389-
// Warning: (ae-forgotten-export) The symbol "MessagingDevicesResponse" needs to be exported by the entry point default-namespace.d.ts
390-
export type MessagingDevicesResponse = MessagingDevicesResponse;
391383
// Warning: (ae-forgotten-export) The symbol "MessagingOptions" needs to be exported by the entry point default-namespace.d.ts
392384
export type MessagingOptions = MessagingOptions;
393385
// Warning: (ae-forgotten-export) The symbol "MessagingPayload" needs to be exported by the entry point default-namespace.d.ts
394386
export type MessagingPayload = MessagingPayload;
395387
// Warning: (ae-forgotten-export) The symbol "MessagingTopicManagementResponse" needs to be exported by the entry point default-namespace.d.ts
396388
export type MessagingTopicManagementResponse = MessagingTopicManagementResponse;
397-
// Warning: (ae-forgotten-export) The symbol "MessagingTopicResponse" needs to be exported by the entry point default-namespace.d.ts
398-
export type MessagingTopicResponse = MessagingTopicResponse;
399389
// Warning: (ae-forgotten-export) The symbol "MulticastMessage" needs to be exported by the entry point default-namespace.d.ts
400390
export type MulticastMessage = MulticastMessage;
401391
// Warning: (ae-forgotten-export) The symbol "Notification" needs to be exported by the entry point default-namespace.d.ts

etc/firebase-admin.messaging.api.md

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,8 @@ export class Messaging {
191191
// @deprecated
192192
enableLegacyHttpTransport(): void;
193193
send(message: Message, dryRun?: boolean): Promise<string>;
194-
// @deprecated
195-
sendAll(messages: Message[], dryRun?: boolean): Promise<BatchResponse>;
196194
sendEach(messages: Message[], dryRun?: boolean): Promise<BatchResponse>;
197195
sendEachForMulticast(message: MulticastMessage, dryRun?: boolean): Promise<BatchResponse>;
198-
// @deprecated
199-
sendMulticast(message: MulticastMessage, dryRun?: boolean): Promise<BatchResponse>;
200-
// @deprecated
201-
sendToCondition(condition: string, payload: MessagingPayload, options?: MessagingOptions): Promise<MessagingConditionResponse>;
202-
// @deprecated
203-
sendToDevice(registrationTokenOrTokens: string | string[], payload: MessagingPayload, options?: MessagingOptions): Promise<MessagingDevicesResponse>;
204-
// @deprecated
205-
sendToDeviceGroup(notificationKey: string, payload: MessagingPayload, options?: MessagingOptions): Promise<MessagingDeviceGroupResponse>;
206-
// @deprecated
207-
sendToTopic(topic: string, payload: MessagingPayload, options?: MessagingOptions): Promise<MessagingTopicResponse>;
208196
subscribeToTopic(registrationTokenOrTokens: string | string[], topic: string): Promise<MessagingTopicManagementResponse>;
209197
unsubscribeFromTopic(registrationTokenOrTokens: string | string[], topic: string): Promise<MessagingTopicManagementResponse>;
210198
}
@@ -308,40 +296,6 @@ export class MessagingClientErrorCode {
308296
};
309297
}
310298

311-
// @public
312-
export interface MessagingConditionResponse {
313-
messageId: number;
314-
}
315-
316-
// @public @deprecated
317-
export interface MessagingDeviceGroupResponse {
318-
failedRegistrationTokens: string[];
319-
failureCount: number;
320-
successCount: number;
321-
}
322-
323-
// @public @deprecated
324-
export interface MessagingDeviceResult {
325-
canonicalRegistrationToken?: string;
326-
// Warning: (ae-forgotten-export) The symbol "FirebaseError" needs to be exported by the entry point index.d.ts
327-
error?: FirebaseError;
328-
messageId?: string;
329-
}
330-
331-
// @public @deprecated
332-
export interface MessagingDevicesResponse {
333-
// (undocumented)
334-
canonicalRegistrationTokenCount: number;
335-
// (undocumented)
336-
failureCount: number;
337-
// (undocumented)
338-
multicastId: number;
339-
// (undocumented)
340-
results: MessagingDeviceResult[];
341-
// (undocumented)
342-
successCount: number;
343-
}
344-
345299
// @public
346300
export interface MessagingOptions {
347301
// (undocumented)
@@ -369,11 +323,6 @@ export interface MessagingTopicManagementResponse {
369323
successCount: number;
370324
}
371325

372-
// @public
373-
export interface MessagingTopicResponse {
374-
messageId: number;
375-
}
376-
377326
// @public
378327
export interface MulticastMessage extends BaseMessage {
379328
// (undocumented)
@@ -407,6 +356,7 @@ export interface NotificationMessagePayload {
407356

408357
// @public
409358
export interface SendResponse {
359+
// Warning: (ae-forgotten-export) The symbol "FirebaseError" needs to be exported by the entry point index.d.ts
410360
error?: FirebaseError;
411361
messageId?: string;
412362
success: boolean;

src/messaging/batch-request-internal.ts

Lines changed: 0 additions & 141 deletions
This file was deleted.

src/messaging/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,8 @@ export {
5656

5757
// Legacy APIs
5858
DataMessagePayload,
59-
MessagingConditionResponse,
60-
MessagingDeviceGroupResponse,
61-
MessagingDeviceResult,
62-
MessagingDevicesResponse,
6359
MessagingOptions,
6460
MessagingPayload,
65-
MessagingTopicResponse,
6661
NotificationMessagePayload,
6762
} from './messaging-api';
6863

src/messaging/messaging-api-request-internal.ts

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,14 @@ import {
2222
AuthorizedHttp2Client, Http2SessionHandler, Http2RequestConfig,
2323
} from '../utils/api-request';
2424
import { createFirebaseError, getErrorCode } from './messaging-errors-internal';
25-
import { SubRequest, BatchRequestClient } from './batch-request-internal';
2625
import { getSdkVersion } from '../utils/index';
27-
import { SendResponse, BatchResponse } from './messaging-api';
26+
import { SendResponse } from './messaging-api';
2827

2928

3029
// FCM backend constants
3130
const FIREBASE_MESSAGING_TIMEOUT = 15000;
32-
const FIREBASE_MESSAGING_BATCH_URL = 'https://fcm.googleapis.com/batch';
3331
const FIREBASE_MESSAGING_HTTP_METHOD: HttpMethod = 'POST';
3432
const FIREBASE_MESSAGING_HEADERS = {
35-
'X-Firebase-Client': `fire-admin-node/${getSdkVersion()}`,
36-
'X-Goog-Api-Client': `gl-node/${process.versions.node} fire-admin/${getSdkVersion()}`
37-
};
38-
const LEGACY_FIREBASE_MESSAGING_HEADERS = {
3933
'X-Firebase-Client': `fire-admin-node/${getSdkVersion()}`,
4034
'X-Goog-Api-Client': `gl-node/${process.versions.node} fire-admin/${getSdkVersion()}`,
4135
'access_token_auth': 'true',
@@ -48,7 +42,6 @@ const LEGACY_FIREBASE_MESSAGING_HEADERS = {
4842
export class FirebaseMessagingRequestHandler {
4943
private readonly httpClient: AuthorizedHttpClient;
5044
private readonly http2Client: AuthorizedHttp2Client;
51-
private readonly batchClient: BatchRequestClient;
5245

5346
/**
5447
* @param app - The app used to fetch access tokens to sign API requests.
@@ -57,8 +50,6 @@ export class FirebaseMessagingRequestHandler {
5750
constructor(app: App) {
5851
this.httpClient = new AuthorizedHttpClient(app as FirebaseApp);
5952
this.http2Client = new AuthorizedHttp2Client(app as FirebaseApp);
60-
this.batchClient = new BatchRequestClient(
61-
this.httpClient, FIREBASE_MESSAGING_BATCH_URL, FIREBASE_MESSAGING_HEADERS);
6253
}
6354

6455
/**
@@ -74,7 +65,7 @@ export class FirebaseMessagingRequestHandler {
7465
method: FIREBASE_MESSAGING_HTTP_METHOD,
7566
url: `https://${host}${path}`,
7667
data: requestData,
77-
headers: LEGACY_FIREBASE_MESSAGING_HEADERS,
68+
headers: FIREBASE_MESSAGING_HEADERS,
7869
timeout: FIREBASE_MESSAGING_TIMEOUT,
7970
};
8071
return this.httpClient.send(request).then((response) => {
@@ -116,7 +107,7 @@ export class FirebaseMessagingRequestHandler {
116107
method: FIREBASE_MESSAGING_HTTP_METHOD,
117108
url: `https://${host}${path}`,
118109
data: requestData,
119-
headers: LEGACY_FIREBASE_MESSAGING_HEADERS,
110+
headers: FIREBASE_MESSAGING_HEADERS,
120111
timeout: FIREBASE_MESSAGING_TIMEOUT,
121112
};
122113
return this.httpClient.send(request).then((response) => {
@@ -146,7 +137,7 @@ export class FirebaseMessagingRequestHandler {
146137
method: FIREBASE_MESSAGING_HTTP_METHOD,
147138
url: `https://${host}${path}`,
148139
data: requestData,
149-
headers: LEGACY_FIREBASE_MESSAGING_HEADERS,
140+
headers: FIREBASE_MESSAGING_HEADERS,
150141
timeout: FIREBASE_MESSAGING_TIMEOUT,
151142
http2SessionHandler: http2SessionHandler
152143
};
@@ -162,35 +153,6 @@ export class FirebaseMessagingRequestHandler {
162153
});
163154
}
164155

165-
/**
166-
* Sends the given array of sub requests as a single batch to FCM, and parses the result into
167-
* a `BatchResponse` object.
168-
*
169-
* @param requests - An array of sub requests to send.
170-
* @returns A promise that resolves when the send operation is complete.
171-
*/
172-
public sendBatchRequest(requests: SubRequest[]): Promise<BatchResponse> {
173-
return this.batchClient.send(requests)
174-
.then((responses: RequestResponse[]) => {
175-
return responses.map((part: RequestResponse) => {
176-
return this.buildSendResponse(part);
177-
});
178-
}).then((responses: SendResponse[]) => {
179-
const successCount: number = responses.filter((resp) => resp.success).length;
180-
return {
181-
responses,
182-
successCount,
183-
failureCount: responses.length - successCount,
184-
};
185-
}).catch((err) => {
186-
if (err instanceof RequestResponseError) {
187-
throw createFirebaseError(err);
188-
}
189-
// Re-throw the error if it already has the proper format.
190-
throw err;
191-
});
192-
}
193-
194156
private buildSendResponse(response: RequestResponse): SendResponse {
195157
const result: SendResponse = {
196158
success: response.status === 200,

0 commit comments

Comments
 (0)