Skip to content

Commit ed80b04

Browse files
committed
change(fcm): Remove deprecated FCM APIs
1 parent 3ae5c63 commit ed80b04

12 files changed

+105
-3610
lines changed

etc/firebase-admin.api.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -382,22 +382,12 @@ export namespace messaging {
382382
export type Message = Message;
383383
// Warning: (ae-forgotten-export) The symbol "Messaging" needs to be exported by the entry point default-namespace.d.ts
384384
export type Messaging = Messaging;
385-
// Warning: (ae-forgotten-export) The symbol "MessagingConditionResponse" needs to be exported by the entry point default-namespace.d.ts
386-
export type MessagingConditionResponse = MessagingConditionResponse;
387-
// Warning: (ae-forgotten-export) The symbol "MessagingDeviceGroupResponse" needs to be exported by the entry point default-namespace.d.ts
388-
export type MessagingDeviceGroupResponse = MessagingDeviceGroupResponse;
389-
// Warning: (ae-forgotten-export) The symbol "MessagingDeviceResult" needs to be exported by the entry point default-namespace.d.ts
390-
export type MessagingDeviceResult = MessagingDeviceResult;
391-
// Warning: (ae-forgotten-export) The symbol "MessagingDevicesResponse" needs to be exported by the entry point default-namespace.d.ts
392-
export type MessagingDevicesResponse = MessagingDevicesResponse;
393385
// Warning: (ae-forgotten-export) The symbol "MessagingOptions" needs to be exported by the entry point default-namespace.d.ts
394386
export type MessagingOptions = MessagingOptions;
395387
// Warning: (ae-forgotten-export) The symbol "MessagingPayload" needs to be exported by the entry point default-namespace.d.ts
396388
export type MessagingPayload = MessagingPayload;
397389
// Warning: (ae-forgotten-export) The symbol "MessagingTopicManagementResponse" needs to be exported by the entry point default-namespace.d.ts
398390
export type MessagingTopicManagementResponse = MessagingTopicManagementResponse;
399-
// Warning: (ae-forgotten-export) The symbol "MessagingTopicResponse" needs to be exported by the entry point default-namespace.d.ts
400-
export type MessagingTopicResponse = MessagingTopicResponse;
401391
// Warning: (ae-forgotten-export) The symbol "MulticastMessage" needs to be exported by the entry point default-namespace.d.ts
402392
export type MulticastMessage = MulticastMessage;
403393
// Warning: (ae-forgotten-export) The symbol "Notification" needs to be exported by the entry point default-namespace.d.ts
@@ -511,8 +501,8 @@ export function storage(app?: App): storage.Storage;
511501

512502
// @public (undocumented)
513503
export namespace storage {
514-
// Warning: (ae-forgotten-export) The symbol "Storage" needs to be exported by the entry point default-namespace.d.ts
515-
export type Storage = Storage;
504+
// Warning: (ae-forgotten-export) The symbol "Storage_2" needs to be exported by the entry point default-namespace.d.ts
505+
export type Storage = Storage_2;
516506
}
517507

518508
```

etc/firebase-admin.messaging.api.md

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,8 @@ export class Messaging {
193193
// @deprecated
194194
enableLegacyHttpTransport(): void;
195195
send(message: Message, dryRun?: boolean): Promise<string>;
196-
// @deprecated
197-
sendAll(messages: Message[], dryRun?: boolean): Promise<BatchResponse>;
198196
sendEach(messages: Message[], dryRun?: boolean): Promise<BatchResponse>;
199197
sendEachForMulticast(message: MulticastMessage, dryRun?: boolean): Promise<BatchResponse>;
200-
// @deprecated
201-
sendMulticast(message: MulticastMessage, dryRun?: boolean): Promise<BatchResponse>;
202-
// @deprecated
203-
sendToCondition(condition: string, payload: MessagingPayload, options?: MessagingOptions): Promise<MessagingConditionResponse>;
204-
// @deprecated
205-
sendToDevice(registrationTokenOrTokens: string | string[], payload: MessagingPayload, options?: MessagingOptions): Promise<MessagingDevicesResponse>;
206-
// @deprecated
207-
sendToDeviceGroup(notificationKey: string, payload: MessagingPayload, options?: MessagingOptions): Promise<MessagingDeviceGroupResponse>;
208-
// @deprecated
209-
sendToTopic(topic: string, payload: MessagingPayload, options?: MessagingOptions): Promise<MessagingTopicResponse>;
210198
subscribeToTopic(registrationTokenOrTokens: string | string[], topic: string): Promise<MessagingTopicManagementResponse>;
211199
unsubscribeFromTopic(registrationTokenOrTokens: string | string[], topic: string): Promise<MessagingTopicManagementResponse>;
212200
}
@@ -310,40 +298,6 @@ export class MessagingClientErrorCode {
310298
};
311299
}
312300

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

374-
// @public
375-
export interface MessagingTopicResponse {
376-
messageId: number;
377-
}
378-
379328
// @public
380329
export interface MulticastMessage extends BaseMessage {
381330
// (undocumented)
@@ -409,6 +358,7 @@ export interface NotificationMessagePayload {
409358

410359
// @public
411360
export interface SendResponse {
361+
// Warning: (ae-forgotten-export) The symbol "FirebaseError" needs to be exported by the entry point index.d.ts
412362
error?: FirebaseError;
413363
messageId?: string;
414364
success: boolean;

etc/firebase-admin.storage.api.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ export function getDownloadURL(file: File_2): Promise<string>;
1616
// Warning: (ae-forgotten-export) The symbol "App" needs to be exported by the entry point index.d.ts
1717
//
1818
// @public
19-
export function getStorage(app?: App): Storage;
19+
export function getStorage(app?: App): Storage_2;
2020

2121
// @public
22-
export class Storage {
22+
class Storage_2 {
2323
get app(): App;
2424
bucket(name?: string): Bucket;
2525
}
26+
export { Storage_2 as Storage }
2627

2728
```

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: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,13 @@ 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';
34-
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-
};
3832
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()}`,
@@ -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
/**
@@ -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)