Skip to main content

Firebase Crashlytics Capacitor plugin

Capacitor plugin for Firebase Crashlytics

Install

bun add @capgo/capacitor-firebase-crashlytics bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-firebase-crashlytics
  • pnpm add @capgo/capacitor-firebase-crashlytics
  • yarn add @capgo/capacitor-firebase-crashlytics

Guide

How to use Firebase Crashlytics in Capacitor

Using @capgo/capacitor-firebase-crashlytics

Capacitor plugin for Firebase Crashlytics.

Install

bun add @capgo/capacitor-firebase-crashlytics
bunx cap sync

bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.

Import

import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';

API at a glance

Method Description
crash Forces a crash to test the implementation.
setCustomKey Sets a custom key and value that is associated with subsequent fatal and non-fatal reports.
setUserId Sets a user ID (identifier) that is associated with subsequent fatal and non-fatal reports.
log Adds a custom log message that is sent with your crash data to give yourself more context for the events leading up to a crash.
setEnabled Enables/disables automatic data collection. The value does not apply until the next run of the app.
isEnabled Returns whether or not automatic data collection is enabled.
didCrashOnPreviousExecution Returns whether the app crashed during the previous execution.
sendUnsentReports Uploads any unsent reports to Crashlytics at next startup.
deleteUnsentReports Deletes any unsent reports on the device.
recordException Records a non-fatal report to send to Crashlytics.

Examples

crash()

Forces a crash to test the implementation.

import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';

await FirebaseCrashlytics.crash({ message: 'Hello from Capacitor' });

setCustomKey()

Sets a custom key and value that is associated with subsequent fatal and non-fatal reports.

import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';

await FirebaseCrashlytics.setCustomKey({
  key: 'key-123',
  value: 'value',
  type: 'string',
});

setUserId()

Sets a user ID (identifier) that is associated with subsequent fatal and non-fatal reports.

import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';

await FirebaseCrashlytics.setUserId({ userId: 'user-id-123' });

log()

Adds a custom log message that is sent with your crash data to give yourself more context for the events leading up to a crash.

import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';

await FirebaseCrashlytics.log({ message: 'Hello from Capacitor' });

setEnabled()

Enables/disables automatic data collection. The value does not apply until the next run of the app.

import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';

await FirebaseCrashlytics.setEnabled({ enabled: true });

isEnabled()

Returns whether or not automatic data collection is enabled.

import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';

const result = await FirebaseCrashlytics.isEnabled();
console.log(result);

The table above lists the 10 core methods. Listener and version helpers, and the full contract of each method, are documented in the GitHub repository.

Full reference

Keep going from Using @capgo/capacitor-firebase-crashlytics

If you are using Using @capgo/capacitor-firebase-crashlytics to plan native plugin work, connect it with Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins, Ionic Enterprise Plugin Alternatives for the product workflow in Ionic Enterprise Plugin Alternatives, and Capgo Native Builds for the product workflow in Capgo Native Builds.

FAQ

Firebase Crashlytics plugin FAQ

How do I install the Firebase Crashlytics plugin in a Capacitor app?

Run "bun add @capgo/capacitor-firebase-crashlytics" (or "npm install @capgo/capacitor-firebase-crashlytics"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-firebase-crashlytics" in your app code.

Does @capgo/capacitor-firebase-crashlytics work with React, Vue and Angular?

Yes. Firebase Crashlytics is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-firebase-crashlytics support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-firebase-crashlytics free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-firebase/tree/main/packages/crashlytics and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses Firebase Crashlytics without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship Firebase Crashlytics changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo