A Google Firebase Crashlytics plugin to enable capture of crash reports.
From the Google documentation (https://firebase.google.com/products/crashlytics/):
Firebase Crashlytics helps you track, prioritize, and fix stability issues that erode app quality, in realtime. Spend less time triaging and troubleshooting crashes and more time building app features that delight users
This plugin supports the following platforms:
cordova plugin add cordova-plugin-firebase-crashlytics --variable ANDROID_FIREBASE_CORE_VERSION=16.0.0 --save
or
phonegap plugin add cordova-plugin-firebase-crashlytics --variable ANDROID_FIREBASE_CORE_VERSION=16.0.0
Omitting FIREBASE_VERSION
will use a default value.
You must ensure that google-services.json
is put in the correct location. This can be achieved using the following in your config.xml
:
<platform name="android">
<resource-file src="https://github.com/ReallySmallSoftware/cordova-plugin-firebase-crashlytics/raw/master/google-services.json" target="google-services.json" />
</platform>
In order to ensure Firebase initialises correctly on Android this plugin can be used. This is not automatically added as a dependency to allow for the configuration it performs to be done manually if desired.
iOS requires GoogleService-Info.plist
is put in the correct location. Similarly this can be done as follows:
<platform name="ios">
<resource-file src="https://github.com/ReallySmallSoftware/cordova-plugin-firebase-crashlytics/raw/master/GoogleService-Info.plist" />
</platform>
At this time it is necessary to manually add the use_frameworks!
directive to this file.
If using multiple Firebase plugins it may be necessary to enable this.
Simply add the plugin to get the default Crashlytics functionality. Note that crashes and logged exceptions will only be reported when the application restarts.
In order to log caught exceptions the following can be used:
var crashlytics = FirebaseCrashlytics.initialise();
crashlytics.logException("my caught exception");
Generate a forced crash. Visible in console after restart of application.
Log a priority message. Will only be logged in the event of a crash.
Available priorities are compatible with most Android Log constants:
Example usage
crashlytics.logPriority(FirebaseCrashlytics.LOG.WARN, 'dashboard', 'This should not happened')
Initialise Crashlytics and send any logs files if the user has given consent, otherwise delete them.
Returns a true if there was a previous crash.
Log a message. Will only be logged in the event of a crash.
Log when a handled exception has happened. Visible in console after restart of application.
Set extra key/value string value. Will only be logged in the event of a crash.
Set extra key/value bool value. Will only be logged in the event of a crash.
Set extra key/value double value. Will only be logged in the event of a crash.
Set extra key/value float value. Will only be logged in the event of a crash.
Set extra key/value integer value. Will only be logged in the event of a crash.
Set the identifier for the user. Take care when using this method and ensure you privacy policy is updated accordingly.
Support is now included for typescript. Use the following to reference the typescript definitions:
/// <reference types="cordova-plugin-firebase-crashlytics" />
private static crashlytics: FirebaseCrashlytics.FirebaseCrashlytics = FirebaseCrashlytics.initialise();
crashlytics.logException("my message");
You may also need to add an external to webpack.config.ls:
externals: {
'cordova-plugin-firebase-crashlytics': "cordova-plugin-firebase-crashlytics"
'/exec':"cordova/exec"
},