Hi Guys, I am integrating Firebase Crashlytics in ...
# multiplatform
k
Hi Guys, I am integrating Firebase Crashlytics in my Multiplatform app and was able to successfully integrate it, but when I started implementing an ExceptionRecorder where I'm using
Crashlytics.record(exception)
to log the exception on Firebase, for android everything is working fine but for I'm unable to record custom logs. Given below is the code I wrote for IOS by importing FirebaseCrashlytics pod using cocoapods plugin.
Copy code
import cocoapods.FirebaseCrashlytics.FIRCrashlytics
import kotlinx.cinterop.ExperimentalForeignApi
import platform.Foundation.NSError
import platform.Foundation.NSLocalizedDescriptionKey

actual class AppCrashlytics actual constructor() {
 
  @OptIn(ExperimentalForeignApi::class)
  actual fun setUserId(userId: String) {
    FIRCrashlytics.crashlytics().setUserID(userId)
  }
 
  @OptIn(ExperimentalForeignApi::class)
  actual fun recordException(error: Throwable) {
    val nsError = NSError.errorWithDomain(
      domain = "<http://com.example.app|com.example.app>",
      code = 123,
      userInfo = mapOf(
        NSLocalizedDescriptionKey to (error::class.simpleName ?: "Unknown error"),
        "reason" to (error.message ?: "Unknown error"),
      ),
    )
    FIRCrashlytics.crashlytics().recordError(nsError)
  }
}
please help me in fixing this issue
any help?
Apologies for the trouble folks, this implementation is working fine, the exception logs took a lot of time to get reflected on the dashboard.
d
Did you get the Analytics working as well?
k
haven't tried analytics till now but will let you know whenever I try to integrate that, but mostly I'll go with the cocoapods plugin approach
d
Yeah, thanks, I tried to use Analytics & Crashlytics a while back and it just would not work at all. I am also using cocoapods