JSPM

  • Created
  • Published
  • Downloads 756
  • Score
    100M100P100Q107280F
  • License MIT

Cordova plugin for Firebase Crashlytics

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cordova-plugin-firebase-crash) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Cordova plugin for Firebase Crashlytics

    NPM version NPM downloads NPM total downloads PayPal donate Twitter

    Donate Your help is appreciated. Create a PR, submit a bug or just grab me 🍺

    Index

    Supported Platforms

    • iOS
    • Android

    Installation

    $ 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"

    Disable data collection

    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.

    Adding required configuration files

    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.

    1. Put google-services.json and/or GoogleService-Info.plist into the root directory of your Cordova project
    2. 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.

    Functions

    log(message): Promise<void>

    Add logging that will be sent with your crash data in case of app crash.

    See

    https://firebase.google.com/docs/crashlytics/customize-crash-reports?authuser=0#add_custom_log_messages

    Example

    cordova.plugins.firebase.crashlytics.log("my custom log message");

    Parameters

    Name Type Description
    message string Log message

    Returns

    Promise<void>

    Callback when operation is completed

    logError(message): Promise<void>

    Log non-fatal exceptions in addition to automatically reported app crashes.

    See

    https://firebase.google.com/docs/crashlytics/customize-crash-reports?authuser=0#log_non-fatal_exceptions

    Example

    cordova.plugins.firebase.crashlytics.logError("my non-fatal exception message");

    Parameters

    Name Type Description
    message string Log message

    Returns

    Promise<void>

    Callback when operation is completed

    setCustomKey(key, value): Promise<void>

    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);

    Parameters

    Name Type Description
    key string Name of the custom key
    value string | number | boolean Value of the custom key

    Returns

    Promise<void>

    Callback when operation is completed

    setEnabled(enabled): Promise<void>

    Sets whether crashlytics collection is enabled for this app on this device.

    Example

    cordova.plugins.firebase.crashlytics.setEnabled(false);

    Parameters

    Name Type Description
    enabled boolean Flag that specifies new state

    Returns

    Promise<void>

    Callback when operation is completed

    setUserId(userId): Promise<void>

    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");

    Parameters

    Name Type Description
    userId string User's indentifier string

    Returns

    Promise<void>

    Callback when operation is completed