Cordova plugin for Firebase Crashlytics
Your help is appreciated. Create a PR, submit a bug or just grab me 🍺 |
---|
- iOS
- Android
$ cordova plugin add cordova-plugin-firebase-crash
If you get an error about CocoaPods being unable to find compatible versions, run
$ pod repo update
Use variables IOS_FIREBASE_POD_VERSION
ANDROID_FIREBASE_BOM_VERSION
to override dependency versions for Firebase SDKs:
$ cordova plugin add cordova-plugin-firebase-crash \
--variable IOS_FIREBASE_POD_VERSION="9.3.0" \
--variable ANDROID_FIREBASE_BOM_VERSION="30.3.1"
In some cases, you may wish to temporarily or permanently disable collection of crash data. You can set the value of variable CRASHLYTICS_COLLECTION_ENABLED
to false
to prevent collecting any user data:
$ cordova plugin add cordova-plugin-firebase-crash \
--variable CRASHLYTICS_COLLECTION_ENABLED=false
Later you can re-enable crashlytics (for instance after getting end-user consent) using method setEnabled.
Cordova supports resource-file
tag for easy copying resources files. Firebase SDK requires google-services.json
on Android and GoogleService-Info.plist
on iOS platforms.
- Put
google-services.json
and/orGoogleService-Info.plist
into the root directory of your Cordova project - Add new tag for Android platform
<platform name="android">
...
<resource-file src="google-services.json" target="app/google-services.json" />
</platform>
...
<platform name="ios">
...
<resource-file src="GoogleService-Info.plist" />
</platform>
This way config files will be copied on cordova prepare
step.
Add logging that will be sent with your crash data in case of app crash.
See
Example
cordova.plugins.firebase.crashlytics.log("my custom log message");
Name | Type | Description |
---|---|---|
message |
string |
Log message |
Promise
<void
>
Callback when operation is completed
Log non-fatal exceptions in addition to automatically reported app crashes.
See
Example
cordova.plugins.firebase.crashlytics.logError("my non-fatal exception message");
Name | Type | Description |
---|---|---|
message |
string |
Log message |
Promise
<void
>
Callback when operation is completed
Add custom key/value pairs to crashlytics report.
See
https://firebase.google.com/docs/crashlytics/customize-crash-reports?platform=android
Example
cordova.plugins.firebase.crashlytics.setCustomKey("my-string-key", "test value");
cordova.plugins.firebase.crashlytics.setCustomKey("my-number-key", 123);
cordova.plugins.firebase.crashlytics.setCustomKey("my-boolean-key", true);
Name | Type | Description |
---|---|---|
key |
string |
Name of the custom key |
value |
string | number | boolean |
Value of the custom key |
Promise
<void
>
Callback when operation is completed
Sets whether crashlytics collection is enabled for this app on this device.
Example
cordova.plugins.firebase.crashlytics.setEnabled(false);
Name | Type | Description |
---|---|---|
enabled |
boolean |
Flag that specifies new state |
Promise
<void
>
Callback when operation is completed
Sets the user identifier property for crashlytics reporting.
See
https://firebase.google.com/docs/crashlytics/customize-crash-reports?authuser=0#set_user_identifiers
Example
cordova.plugins.firebase.crashlytics.setUserId("12345");
Name | Type | Description |
---|---|---|
userId |
string |
User's indentifier string |
Promise
<void
>
Callback when operation is completed