firebase-admin package

Firebase 命名空間 API (舊版)。

函式

函式 說明
app(名稱)
appCheck(應用程式) 取得預設應用程式或特定應用程式的 AppCheck 服務。admin.appCheck() 可以在沒有引數的情況下呼叫 admin.appCheck(),藉此存取預設應用程式的 AppCheck 服務,或做為 admin.appCheck(app),以存取與特定應用程式相關聯的 AppCheck 服務。
auth(應用程式) 取得預設應用程式或特定應用程式的 Auth 服務。admin.auth() 可以在沒有引數的情況下呼叫,藉此存取預設應用程式的 Auth 服務,而 admin.auth(app) 可用來存取與特定應用程式相關聯的 Auth 服務。
資料庫(應用程式) 取得預設應用程式或特定應用程式的 Database 服務。不需引數即可呼叫 admin.database(),藉此存取預設應用程式的 Database 服務,也可以當做 admin.database(app) 來呼叫 admin.database(app),以存取與特定應用程式相關聯的 Database 服務。admin.database 也是可用來存取與 Database 服務相關聯的全域常數和方法的命名空間。
firestore(應用程式)
initializeApp(選項, 名稱)
installations(應用程式) 取得預設應用程式或特定應用程式的「安裝」服務。admin.installations() 可以在沒有引數的情況下呼叫 admin.installations(),藉此存取預設應用程式的「安裝」服務,或使用 admin.installations(app) 存取與特定應用程式相關聯的「安裝」服務。
instanceId(應用程式) 取得預設應用程式或特定應用程式的 InstanceId 服務。admin.instanceId() 可以在沒有引數的情況下呼叫 admin.instanceId(),藉此存取預設應用程式的 InstanceId 服務,也可當做 admin.instanceId(app) 以存取與特定應用程式相關聯的 InstanceId 服務。
machineLearning(應用程式) 取得預設應用程式或特定應用程式的 MachineLearning 服務。admin.machineLearning() 可以呼叫 admin.machineLearning(),而無需使用引數來存取預設應用程式的 MachineLearning 服務,或當做 admin.machineLearning(app) 以存取與特定應用程式相關聯的 MachineLearning 服務。
訊息(應用程式) 取得預設應用程式或特定應用程式的「訊息」服務。不用引數即可呼叫 admin.messaging(),藉此存取預設應用程式的 Messaging 服務,也可以做為 admin.messaging(app) 來存取與特定應用程式相關聯的 Messaging 服務。
projectManagement(應用程式) 取得預設應用程式或特定應用程式的 ProjectManagement 服務。admin.projectManagement() 可以不使用引數來呼叫 admin.projectManagement(),藉此存取預設應用程式的 ProjectManagement 服務,也可以當做 admin.projectManagement(app) 以存取與特定應用程式相關聯的 ProjectManagement 服務。
remoteConfig(應用程式) 取得預設應用程式或特定應用程式的 RemoteConfig 服務。無需引數即可呼叫 admin.remoteConfig(),藉此存取預設應用程式的 RemoteConfig 服務,也可以做為 admin.remoteConfig(app) 來存取與特定應用程式相關聯的 RemoteConfig 服務。
securityRules(應用程式) 取得預設應用程式或特定應用程式的 SecurityRules 服務。admin.securityRules() 可以在沒有引數的情況下呼叫 admin.securityRules(),藉此存取預設應用程式的 SecurityRules 服務;如果呼叫 admin.securityRules(app),則可存取與特定應用程式相關聯的 SecurityRules 服務。
storage(應用程式) 取得預設應用程式或特定應用程式的 Storage 服務。不用引數即可呼叫 admin.storage(),藉此存取預設應用程式的 Storage 服務,也可呼叫 admin.storage(app) 以存取與特定應用程式相關聯的 Storage 服務。

介面

介面 說明
應用程式選項 可傳遞給 initializeApp() 的可用選項。
FirebaseArrayIndexError 複合類型,包含 FirebaseError 物件,以及可用來取得錯誤項目的索引。
FirebaseError FirebaseError 是標準 JavaScript Error 物件的子類別。除了訊息字串和堆疊追蹤之外,其中包含字串程式碼。
GoogleOAuthAccessToken Google OAuth 2.0 存取權杖介面。
服務帳戶

命名空間

命名空間 說明
應用程式
appCheck
驗證
憑證
資料庫
Firestore
安裝
instanceId
machineLearning
訊息
專案管理
remoteConfig
securityRules
儲存空間

變數

變數 說明
應用程式
SDK_VERSION

app(名稱)

簽名:

export declare function app(name?: string): app.App;

參數

參數 類型 說明
name 字串

傳回:

app.App

appCheck(應用程式)

取得預設應用程式或特定應用程式的 AppCheck 服務。

呼叫 admin.appCheck() 時無需引數,即可存取預設應用程式的 AppCheck 服務,或做為 admin.appCheck(app) 存取與特定應用程式相關聯的 AppCheck 服務。

簽名:

export declare function appCheck(app?: App): appCheck.AppCheck;

參數

參數 類型 說明
app 應用程式 用於傳回 AppCheck 服務的選用應用程式。如未提供,系統會傳回預設的 AppCheck 服務。

傳回:

appCheck.AppCheck

預設的 AppCheck 服務 (如未提供應用程式),或與所提供應用程式相關聯的 AppCheck 服務。

範例 1

// Get the `AppCheck` service for the default app
var defaultAppCheck = admin.appCheck();

範例 2

// Get the `AppCheck` service for a given app
var otherAppCheck = admin.appCheck(otherApp);

auth(應用程式)

取得預設應用程式或特定應用程式的驗證服務。

呼叫 admin.auth() 時無需使用引數,即可存取預設應用程式的 Auth 服務;如果呼叫 admin.auth(app),則可存取與特定應用程式相關聯的 Auth 服務。

簽名:

export declare function auth(app?: App): auth.Auth;

參數

參數 類型 說明
app 應用程式

傳回:

auth.Auth

範例 1

// Get the Auth service for the default app
var defaultAuth = admin.auth();

範例 2

// Get the Auth service for a given app
var otherAuth = admin.auth(otherApp);

資料庫(應用程式)

取得預設應用程式或特定應用程式的 Database 服務。

呼叫 admin.database() 時無需引數,即可存取預設應用程式的 Database 服務,或做為 admin.database(app) 存取與特定應用程式相關聯的 Database 服務。

admin.database 也是命名空間,可用於存取與 Database 服務相關聯的全域常數和方法。

簽名:

export declare function database(app?: App): database.Database;

參數

參數 類型 說明
app 應用程式

傳回:

database.Database

預設的 Database 服務 (如未提供應用程式),或與所提供應用程式相關聯的 Database 服務。

範例 1

// Get the Database service for the default app
var defaultDatabase = admin.database();

範例 2

// Get the Database service for a specific app
var otherDatabase = admin.database(app);

Firestore(應用程式)

簽名:

export declare function firestore(app?: App): _firestore.Firestore;

參數

參數 類型 說明
app 應用程式

傳回:

_firestore.Firestore

InitialApp(選項, 名稱)

簽名:

export declare function initializeApp(options?: AppOptions, name?: string): app.App;

參數

參數 類型 說明
選項 應用程式選項
name 字串

傳回:

app.App

安裝項目(應用程式)

取得預設應用程式或特定應用程式的「安裝」服務。

無需引數即可呼叫 admin.installations(),即可存取預設應用程式的「安裝」服務;如要存取與特定應用程式相關聯的「安裝」服務,則可設為 admin.installations(app)

簽名:

export declare function installations(app?: App): installations.Installations;

參數

參數 類型 說明
app 應用程式 選用應用程式,指定 Installations 服務。如未提供,系統會傳回預設的 Installations 服務。

傳回:

installations.Installations

預設的 Installations 服務 (如未提供應用程式),或與所提供應用程式相關聯的 Installations 服務。

範例 1

// Get the Installations service for the default app
var defaultInstallations = admin.installations();

範例 2

// Get the Installations service for a given app
var otherInstallations = admin.installations(otherApp);

instanceId(應用程式)

取得預設應用程式或特定應用程式的 InstanceId 服務。

呼叫 admin.instanceId() 時無需引數,即可存取預設應用程式的 InstanceId 服務,或做為 admin.instanceId(app) 存取與特定應用程式相關聯的 InstanceId 服務。

簽名:

export declare function instanceId(app?: App): instanceId.InstanceId;

參數

參數 類型 說明
app 應用程式 選用應用程式,指定 InstanceId 服務。如未提供,系統會傳回預設的 InstanceId 服務。

傳回:

instanceId.InstanceId

預設的 InstanceId 服務 (如未提供應用程式),或與所提供應用程式相關聯的 InstanceId 服務。

範例 1

// Get the Instance ID service for the default app
var defaultInstanceId = admin.instanceId();

範例 2

// Get the Instance ID service for a given app
var otherInstanceId = admin.instanceId(otherApp);

MachineLearning(應用程式)

取得預設應用程式或特定應用程式的 MachineLearning 服務。

呼叫 admin.machineLearning() 時無需引數,即可存取預設應用程式的 MachineLearning 服務,或做為 admin.machineLearning(app) 存取與特定應用程式相關聯的 MachineLearning 服務。

簽名:

export declare function machineLearning(app?: App): machineLearning.MachineLearning;

參數

參數 類型 說明
app 應用程式 選用應用程式,指定 MachineLearning 服務。如未提供,系統會傳回預設的 MachineLearning 服務。

傳回:

machineLearning.MachineLearning

預設的 MachineLearning 服務 (如未提供應用程式),或與所提供應用程式相關聯的 MachineLearning 服務。

範例 1

// Get the MachineLearning service for the default app
var defaultMachineLearning = admin.machineLearning();

範例 2

// Get the MachineLearning service for a given app
var otherMachineLearning = admin.machineLearning(otherApp);

訊息(應用程式)

取得預設應用程式或特定應用程式的「訊息」服務。

呼叫 admin.messaging() 時無需引數,即可存取預設應用程式的 Messaging 服務,或做為 admin.messaging(app) 存取與特定應用程式相關聯的 Messaging 服務。

簽名:

export declare function messaging(app?: App): messaging.Messaging;

參數

參數 類型 說明
app 應用程式 選用應用程式,指定 Messaging 服務。如未提供,系統會傳回預設的 Messaging 服務。

傳回:

Messagingsaging.Messaging

預設的 Messaging 服務 (如未提供應用程式),或與所提供應用程式相關聯的 Messaging 服務。

範例 1

// Get the Messaging service for the default app
var defaultMessaging = admin.messaging();

範例 2

// Get the Messaging service for a given app
var otherMessaging = admin.messaging(otherApp);

projectManagement(應用程式)

取得預設應用程式或特定應用程式的 ProjectManagement 服務。

呼叫 admin.projectManagement() 時無需使用引數,即可存取預設應用程式的 ProjectManagement 服務,或做為 admin.projectManagement(app) 來存取與特定應用程式相關聯的 ProjectManagement 服務。

簽名:

export declare function projectManagement(app?: App): projectManagement.ProjectManagement;

參數

參數 類型 說明
app 應用程式 選用應用程式,指定 ProjectManagement 服務。如未提供,系統會傳回預設的 ProjectManagement 服務。*

傳回:

projectManagement.ProjectManagement

預設的 ProjectManagement 服務 (如未提供應用程式),或與所提供應用程式相關聯的 ProjectManagement 服務。

範例 1

// Get the ProjectManagement service for the default app
var defaultProjectManagement = admin.projectManagement();

範例 2

// Get the ProjectManagement service for a given app
var otherProjectManagement = admin.projectManagement(otherApp);

RemoteConfig(應用程式)

取得預設應用程式或特定應用程式的 RemoteConfig 服務。

呼叫 admin.remoteConfig() 時無需引數,即可存取預設應用程式的 RemoteConfig 服務,或做為 admin.remoteConfig(app) 存取與特定應用程式相關聯的 RemoteConfig 服務。

簽名:

export declare function remoteConfig(app?: App): remoteConfig.RemoteConfig;

參數

參數 類型 說明
app 應用程式 用於傳回 RemoteConfig 服務的選用應用程式。如未提供,系統會傳回預設的 RemoteConfig 服務。

傳回:

remoteConfig.RemoteConfig

預設的 RemoteConfig 服務 (如未提供應用程式),或與所提供應用程式相關聯的 RemoteConfig 服務。

範例 1

// Get the `RemoteConfig` service for the default app
var defaultRemoteConfig = admin.remoteConfig();

範例 2

// Get the `RemoteConfig` service for a given app
var otherRemoteConfig = admin.remoteConfig(otherApp);

SecurityRules(應用程式)

取得預設應用程式或特定應用程式的 SecurityRules 服務。

呼叫 admin.securityRules() 時無需使用引數,即可存取預設應用程式的 SecurityRules 服務;如果呼叫 admin.securityRules(app),則可存取與特定應用程式相關聯的 SecurityRules 服務。

簽名:

export declare function securityRules(app?: App): securityRules.SecurityRules;

參數

參數 類型 說明
app 應用程式 用於傳回 SecurityRules 服務 (選用) 的應用程式。如未提供,系統會傳回預設的 SecurityRules 服務。

傳回:

securityRules.SecurityRules

預設的 SecurityRules 服務 (如未提供應用程式),或與所提供應用程式相關聯的 SecurityRules 服務。

範例 1

// Get the SecurityRules service for the default app
var defaultSecurityRules = admin.securityRules();

範例 2

// Get the SecurityRules service for a given app
var otherSecurityRules = admin.securityRules(otherApp);

storage(應用程式)

取得預設應用程式或特定應用程式的 Storage 服務。

呼叫 admin.storage() 時無需引數,即可存取預設應用程式的 Storage 服務,或做為 admin.storage(app) 存取與特定應用程式相關聯的 Storage 服務。

簽名:

export declare function storage(app?: App): storage.Storage;

參數

參數 類型 說明
app 應用程式

傳回:

storage.Storage

範例 1

// Get the Storage service for the default app
var defaultStorage = admin.storage();

範例 2

// Get the Storage service for a given app
var otherStorage = admin.storage(otherApp);

應用程式

簽名:

apps: (app.App | null)[]

SDK_VERSION

簽名:

SDK_VERSION: string