androidiosfirebasereact-nativecrashlytics

How to disable Crashlytics while in debug mode, in react-native-firebase?


I have integrated firebase Crashlytics on a react native application. I want to disable crash logs while working on development mode. How can I disable crash logs in debug mode for both Android and Ios Application. To create crash logs I have followed react native firebase documentation check this official link :: https://rnfirebase.io/docs/v5.x.x/crashlytics/android

I am using react-native-firebase version 5.2.2

I want to disable logs on debug mode without changing the version. I want to add code to disable the crash log for both Android and Ios. Please suggest how this should be done.


Solution

  • The documentation explains how to disable it

    iOS

    Turn off automatic collection with a new key to your Info.plist file:

    Key: firebase_crashlytics_collection_enabled

    Value: false

    <key>firebase_crashlytics_collection_enabled</key>
    <false/>
    

    Android

    Turn off automatic collection with a meta-data tag in your AndroidManifest.xml file:

    <meta-data
        android:name="firebase_crashlytics_collection_enabled"
        android:value="false" />
    

    Enable collection at runtime

    You can can initialise crashlytics in your javascript code using

    firebase.crashlytics().enableCrashlyticsCollection();
    

    You can then use

    if (__DEV__) {
    
    } else {
    
    }
    

    to run any specific code in development or in production.