firebase-admin package

Firebase 命名空间型 API(旧版)。

函数

函数 说明
应用(名称)
appCheck(应用) 获取默认应用或指定应用的 AppCheck 服务。可调用admin.appCheck()且不使用任何参数,以访问默认应用的 AppCheck 服务,或以 admin.appCheck(app) 的形式访问特定应用服务。AppCheck
auth(应用) 获取默认应用或指定应用的 Auth 服务。调用 admin.auth() 时不使用任何参数,即可访问默认应用的 Auth 服务,也可以将其作为 admin.auth(app) 调用,以访问与特定应用相关联的 Auth 服务。
数据库(应用) 获取默认应用或指定应用的 Database 服务。您可以使用不带任何参数调用 admin.database(),以访问默认应用的 Database 服务,也可以将其作为 admin.database(app) 调用,以访问与特定应用关联的 Database 服务。admin.database 也是一个命名空间,可用于访问与 Database 服务关联的全局常量和方法。
firestore(应用)
initializeApp(options, name)
安装(应用) 获取默认应用或指定应用的安装次数服务。可调用 admin.installations() (不使用任何参数)来访问默认应用的安装次数服务,或者以 admin.installations(app) 的身份访问与特定应用相关联的安装次数服务。
instanceId(app) 获取默认应用或指定应用的 InstanceId 服务。可以不使用任何参数调用 admin.instanceId() 以访问默认应用的 InstanceId 服务,或者以 admin.instanceId(app) 的形式调用 admin.instanceId() 以访问与特定应用关联的 InstanceId 服务。
machineLearning(应用) 获取默认应用或指定应用的机器学习服务。可调用admin.machineLearning()不使用任何参数,以访问默认应用的MachineLearning服务,或以admin.machineLearning(app)与特定应用服务相关联的MachineLearning
消息(应用) 获取默认应用或指定应用的 Messaging 服务。可调用admin.messaging()且不使用任何参数,以访问默认应用的 Messaging 服务,或以 admin.messaging(app) 的形式访问Messaging与特定应用相关联的服务。
projectManagement(应用) 获取默认应用或给定应用的 ProjectManagement 服务。可以不使用任何参数调用 admin.projectManagement() 以访问默认应用的 ProjectManagement 服务,或者以 admin.projectManagement(app) 的形式调用 admin.projectManagement() 以访问与特定应用关联的 ProjectManagement 服务。
remoteConfig(应用) 获取默认应用或指定应用的 RemoteConfig 服务。可调用admin.remoteConfig()(不使用任何参数)来访问默认应用的 RemoteConfig 服务,或者以 admin.remoteConfig(app) 的形式调用RemoteConfig以访问特定应用服务。
securityRules(应用) 获取默认应用或指定应用的 SecurityRules 服务。可以在不使用任何参数的情况下调用 admin.securityRules(),以访问默认应用的 SecurityRules 服务,或者以 admin.securityRules(app) 的身份访问与特定应用关联的 SecurityRules 服务。
storage(应用) 获取默认应用或指定应用的 Storage 服务。可以不使用任何参数调用 admin.storage() 以访问默认应用的 Storage 服务,或者以 admin.storage(app) 的形式调用 admin.storage() 以访问与特定应用关联的 Storage 服务。

接口

接口 说明
AppOptions 可以传递给 initializeApp() 的可用选项。
FirebaseArrayIndexError 复合类型,包含 FirebaseError 对象和可用于获取错误项的索引。
FirebaseError FirebaseError 是标准 JavaScript Error 对象的子类。除了消息字符串和堆栈轨迹之外,它还包含字符串代码。
GoogleOAuthAccessToken Google OAuth 2.0 访问令牌的界面。
服务帐号

命名空间

命名空间 说明
应用
appCheck
身份验证
凭据
数据库
firestore
安装次数
instanceId
机器学习
消息
项目管理
remoteConfig
securityRules
存储空间

变量

变量 说明
应用
SDK_VERSION

app(名称)

签名

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

参数

参数 类型 说明
name string

返回

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(应用)

获取默认应用或指定应用的 Auth 服务。

可以调用 admin.auth() 时不使用任何参数,以访问默认应用的 Auth 服务,或者以 admin.auth(app) 的形式调用,以访问与特定应用相关联的 Auth 服务。

签名

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

参数

参数 类型 说明
app 应用

返回

身份验证

示例 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

initializeApp(options, name)

签名

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

参数

参数 类型 说明
选项 AppOptions
名称 string

返回

app.App

安装次数(应用)

获取默认应用或指定应用的安装次数服务。

可调用 admin.installations() 时不使用任何参数,以访问默认应用的安装服务,或以admin.installations(app)的身份访问与特定应用关联的安装服务。

签名

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

参数

参数 类型 说明
app 应用 要返回其 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);

机器学习(应用)

获取默认应用或指定应用的机器学习服务。

可以不使用任何参数调用 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);

消息(应用)

获取默认应用或给定应用的 Messaging 服务。

可以不使用任何参数调用 admin.messaging(),以访问默认应用的 Messaging 服务,或者以 admin.messaging(app) 的形式调用,以访问与特定应用相关联的 Messaging 服务。

签名

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

参数

参数 类型 说明
app 应用 要返回其 Messaging 服务的可选应用。如果未提供,系统将返回默认的 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 服务。

可以不使用任何参数调用 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