入门指南
复制一个包含安装步骤和本插件的完整 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.
Install
Section titled “Install”You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsThen use the following prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-firebase-crashlytics` plugin in my project.如果您更喜欢手动设置,请运行以下命令安装插件并遵循以下平台特定的说明:
bun add @capgo/capacitor-firebase-crashlyticsbunx cap sync导入
标题:导入import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';API概述
标题:API概述crash
标题:崩溃强制崩溃以测试实现。
仅适用于Android和iOS。
import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';
await FirebaseCrashlytics.crash({} as CrashOptions);setCustomKey
《setCustomKey》为后续的致命和非致命报告设置自定义键和值。
仅适用于 Android 和 iOS。
import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';
await FirebaseCrashlytics.setCustomKey({} as SetCustomKeyOptions);setUserId
《setUserId》为后续的致命和非致命报告设置用户 ID(标识符)。
仅适用于 Android 和 iOS。
import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';
await FirebaseCrashlytics.setUserId({} as SetUserIdOptions);log
《log》添加自定义日志消息以提供更多上下文,了解导致崩溃的事件。
仅适用于 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 概述 为实现细节在API概述中 简介 为实现细节在简介中 API密钥 为实现细节在API密钥中 设备 为实现细节在设备中,和 捆绑包 为实现细节在捆绑包中。