iosswiftfirebase-crash-reporting

Firebase Crashlytics debug mode not send report in ios


in swift, how to send crash report only release mode?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

#if DEBUG
    Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(false)
#endif

    return true
}

is it right? (https://firebase.google.com/docs/crashlytics/customize-crash-reports)


Solution

  • Add this to didFinishLaunchingWithOptions method in AppDelegate.

        #if DEBUG
        Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(false)
        Crashlytics.crashlytics().checkForUnsentReports { isUnsendExists in
            if isUnsendExists {
                Crashlytics.crashlytics().deleteUnsentReports()
            }
        }
        #else
        Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(true)
        #endif