@capacitor-community/firebase-crashlytics
Capacitor community plugin for native Firebase Crashlytics.
Maintainer | GitHub | Social |
---|---|---|
Robin Genz | robingenz | @robin_genz |
npm install @capacitor-community/firebase-crashlytics
npx cap sync
Add Firebase to your project if you haven't already (Android / iOS).
See Add Firebase Crashlytics to your app and follow the instructions to set up your app correctly.
This plugin will use the following project variables (defined in your app’s variables.gradle
file):
$firebaseCrashlyticsVersion
version ofcom.google.firebase:firebase-crashlytics
(default:17.4.1
)
No configuration required for this plugin.
import { FirebaseCrashlytics } from '@capacitor-community/firebase-crashlytics';
const crash = async () => {
await FirebaseCrashlytics.crash({ message: 'Test' });
};
const recordException = async () => {
await FirebaseCrashlytics.recordException({
message: "This is a non-fatal message.",
});
};
const setUserId = async () => {
await FirebaseCrashlytics.setUserId({
userId: "123",
});
};
const addLogMessage = async () => {
await FirebaseCrashlytics.addLogMessage({
message: "Test",
});
};
const sendUnsentReports = async () => {
await FirebaseCrashlytics.sendUnsentReports();
};
const deleteUnsentReports = async () => {
await FirebaseCrashlytics.deleteUnsentReports();
};
crash(...)
setContext(...)
setUserId(...)
addLogMessage(...)
setEnabled(...)
isEnabled()
didCrashDuringPreviousExecution()
sendUnsentReports()
deleteUnsentReports()
recordException(...)
- Interfaces
crash(options: { message: string; }) => Promise<void>
Forces a crash to test the implementation.
Only available for Android and iOS.
Param | Type |
---|---|
options |
{ message: string; } |
setContext(options: ContextOptions) => Promise<void>
Sets a custom key and value that is associated with subsequent fatal and non-fatal reports.
Only available for Android and iOS.
Param | Type |
---|---|
options |
ContextOptions |
setUserId(options: { userId: string; }) => Promise<void>
Sets a user ID (identifier) that is associated with subsequent fatal and non-fatal reports.
Only available for Android and iOS.
Param | Type |
---|---|
options |
{ userId: string; } |
addLogMessage(options: { message: string; }) => Promise<void>
Adds a log message that is sent with your crash data. Only visible in the Crashlytics dashboard.
Only available for Android and iOS.
Param | Type |
---|---|
options |
{ message: string; } |
setEnabled(options: { enabled: boolean; }) => Promise<void>
Enables/disables automatic data collection. The value does not apply until the next run of the app.
Only available for Android and iOS.
Param | Type |
---|---|
options |
{ enabled: boolean; } |
isEnabled() => Promise<{ enabled: boolean; }>
Returns whether or not automatic data collection is enabled.
Only available for iOS.
Returns: Promise<{ enabled: boolean; }>
didCrashDuringPreviousExecution() => Promise<{ crashed: boolean; }>
Returns whether the app crashed during the previous execution.
Only available for Android and iOS.
Returns: Promise<{ crashed: boolean; }>
sendUnsentReports() => Promise<void>
Uploads any unsent reports to Crashlytics. When automatic data collection is enabled, Crashlytics automatically uploads reports at startup.
Only available for Android and iOS.
deleteUnsentReports() => Promise<void>
Deletes any unsent reports on the device.
Only available for Android and iOS.
recordException(options: RecordExceptionOptions) => Promise<void>
Records a non-fatal report to send to Crashlytics.
Only available for Android and iOS.
Param | Type |
---|---|
options |
RecordExceptionOptions |
Prop | Type |
---|---|
key |
string |
value |
string | number | boolean |
type |
'string' | 'boolean' | 'long' | 'double' | 'int' | 'float' |
Prop | Type | Description |
---|---|---|
message |
string |
|
code |
number |
Error code within a specific error domain. Only available for iOS. |
domain |
string |
A string containing the error domain. Only available for iOS. |
Here you can find more information on how to test the Firebase Crashlytics implementation. Among other things, you will find information on how to correctly adjust the project's debug settings under iOS and how to test it out.
See CHANGELOG.md.
See LICENSE.