Getting Started
复制一个包含安装步骤和完整 Markdown 指南的配置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-firebase-crashlytics`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/firebase-crashlytics/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
bun add @capgo/capacitor-firebase-crashlyticsbunx cap syncimport { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';crash
Section titled “崩溃”强制崩溃以测试实现。
仅适用于Android和iOS。
import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';
await FirebaseCrashlytics.crash({} as CrashOptions);setCustomKey
Section titled “setCustomKey”设置自定义键值对,用于关联后续的致命和非致命报告。
仅适用于 Android 和 iOS。
import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';
await FirebaseCrashlytics.setCustomKey({} as SetCustomKeyOptions);setUserId
Section titled “setUserId”设置用户 ID(标识符),用于关联后续的致命和非致命报告。
仅适用于 Android 和 iOS。
import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';
await FirebaseCrashlytics.setUserId({} as SetUserIdOptions);添加自定义日志消息,用于与崩溃数据一起发送,提供更多上下文以了解导致崩溃的事件。
仅适用于 Android 和 iOS。
import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';
await FirebaseCrashlytics.log({} as LogOptions);setEnabled
setEnabled启用/禁用自动数据收集。 值直到下一次应用程序运行才生效。
仅适用于Android和iOS。
import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';
await FirebaseCrashlytics.setEnabled({} as SetEnabledOptions);isEnabled
isEnabled返回是否启用了自动数据收集。
仅适用于iOS。
import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';
await FirebaseCrashlytics.isEnabled();didCrashOnPreviousExecution
didCrashOnPreviousExecution返回应用程序在上一次执行期间是否崩溃。
仅适用于Android和iOS。
import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';
await FirebaseCrashlytics.didCrashOnPreviousExecution();sendUnsentReports
Section titled “sendUnsentReports”下次启动时将任何未发送的报告上传到Crashlytics。
当自动数据收集启用时,Crashlytics会在启动时自动上传报告。
仅适用于Android和iOS。
import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';
await FirebaseCrashlytics.sendUnsentReports();deleteUnsentReports
Section titled “deleteUnsentReports”删除设备上的任何未发送的报告。
仅适用于Android和iOS。
import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';
await FirebaseCrashlytics.deleteUnsentReports();recordException
Section titled “recordException”记录一个非致命的报告以发送到Crashlytics。
仅适用于Android和iOS。
import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';
await FirebaseCrashlytics.recordException({} as RecordExceptionOptions);类型参考
类型参考部分CrashOptions
崩溃选项部分export interface CrashOptions { /** * @since 0.1.0 */ message: string;}SetCustomKeyOptions
自定义键选项部分export type SetCustomKeyOptions = CustomKeyAndValue;SetUserIdOptions
设置用户 ID 选项部分export interface SetUserIdOptions { /** * @since 0.1.0 */ userId: string;}LogOptions
日志选项部分export interface LogOptions { /** * @since 0.1.0 */ message: string;}SetEnabledOptions
设置启用选项部分export interface SetEnabledOptions { /** * @since 0.1.0 */ enabled: boolean;}IsEnabledResult
“IsEnabledResult”标题export interface IsEnabledResult { /** * @since 0.1.0 */ enabled: boolean;}DidCrashOnPreviousExecutionResult
“DidCrashOnPreviousExecutionResult”标题export interface DidCrashOnPreviousExecutionResult { /** * @since 0.1.0 */ crashed: boolean;}RecordExceptionOptions
“RecordExceptionOptions”标题export interface RecordExceptionOptions { /** * The message to record as a non-fatal exception. * * @since 0.1.0 */ message: string; /** * Error code within a specific error domain. * * **Attention:** This option is ignored on iOS if `stacktrace` is provided. * * Only available for iOS. * * @since 0.1.0 */ code?: number; /** * A string containing the error domain. * * **Attention:** This option is ignored on iOS if `stacktrace` is provided. * * Only available for iOS. * * @since 0.1.0 */ domain?: string; /** * An array of keys and the values to associate with the non fatal exception, * in addition to the app level custom keys. * * **Attention:** This option is ignored on iOS if `stacktrace` is provided. * * @since 7.1.0 */ keysAndValues?: CustomKeyAndValue[]; /** * A stacktrace generated by stacktrace.js. * * @since 1.1.0 */ stacktrace?: StackFrame[];}GetPluginVersionResult
“GetPluginVersionResult”标题export interface GetPluginVersionResult { /** * The semantic version of this plugin. * * @since 8.0.2 */ version: string;}CustomKeyAndValue
“CustomKeyAndValue”标题export interface CustomKeyAndValue { /** * @since 7.1.0 */ key: string; /** * @since 7.1.0 */ value: string | number | boolean; /** * @since 7.1.0 */ type: 'string' | 'long' | 'double' | 'boolean' | 'int' | 'float';}StackFrame
“StackFrame”标题由 stacktrace.js 生成的栈跟踪子集。
export interface StackFrame { lineNumber?: number; fileName?: string; functionName?: string;}真实来源
真实来源本页面由插件生成。 src/definitions.ts当公共 API 在上游发生变化时,请重新运行同步。
从 Getting Started 继续
从 Getting Started 继续如果您正在使用 Getting Started 来规划仪表板和 API 操作,请将其与 API Overview API概述细节 简介 __CAPGO_KEEP_0__密钥 API密钥细节 for the implementation detail in API Keys, 设备细节 打包 打包细节 编辑页面