UNPKG

2.6 kBJavaScriptView Raw
1/*! firebase-admin v12.0.0 */
2"use strict";
3/*!
4 * Copyright 2020 Google Inc.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18Object.defineProperty(exports, "__esModule", { value: true });
19exports.getInstanceId = exports.InstanceId = void 0;
20/**
21 * Firebase Instance ID service.
22 *
23 * @packageDocumentation
24 */
25const index_1 = require("../app/index");
26const instance_id_1 = require("./instance-id");
27Object.defineProperty(exports, "InstanceId", { enumerable: true, get: function () { return instance_id_1.InstanceId; } });
28/**
29 * Gets the {@link InstanceId} service for the default app or a given app.
30 *
31 * This API is deprecated. Developers are advised to use the
32 * {@link firebase-admin.installations#getInstallations}
33 * API to delete their instance IDs and Firebase installation IDs.
34 *
35 * `getInstanceId()` can be called with no arguments to access the default
36 * app's `InstanceId` service or as `getInstanceId(app)` to access the
37 * `InstanceId` service associated with a specific app.
38 *
39 * @example
40 * ```javascript
41 * // Get the Instance ID service for the default app
42 * const defaultInstanceId = getInstanceId();
43 * ```
44 *
45 * @example
46 * ```javascript
47 * // Get the Instance ID service for a given app
48 * const otherInstanceId = getInstanceId(otherApp);
49 *```
50 *
51 * This API is deprecated. Developers are advised to use the `admin.installations()`
52 * API to delete their instance IDs and Firebase installation IDs.
53 *
54 * @param app - Optional app whose `InstanceId` service to
55 * return. If not provided, the default `InstanceId` service will be
56 * returned.
57 *
58 * @returns The default `InstanceId` service if
59 * no app is provided or the `InstanceId` service associated with the
60 * provided app.
61 *
62 * @deprecated Use {@link firebase-admin.installations#getInstallations} instead.
63 */
64function getInstanceId(app) {
65 if (typeof app === 'undefined') {
66 app = (0, index_1.getApp)();
67 }
68 const firebaseApp = app;
69 return firebaseApp.getOrInitService('instanceId', (app) => new instance_id_1.InstanceId(app));
70}
71exports.getInstanceId = getInstanceId;