> ## Documentation Index
> Fetch the complete documentation index at: https://docs.median.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Firebase Crashlytics

> Track and fix app crashes with Firebase Crashlytics.

Firebase Crashlytics is a real-time crash reporting solution that helps you identify, prioritize, and resolve the most critical issues affecting your app users. This plugin integrates the iOS and Android [Firebase Crashlytics SDKs](https://firebase.google.com/docs/crashlytics/get-started) into your app and supports logging of native crashes, WebView console errors, and (on Android) toast errors.

## Why use Google Firebase Crashlytics

* **App crash events**: Native crash reporting.
* **WebView console errors**: WebView console errors logged to Crashlytics.
* **Android toast errors**: Android-only (for example, SSL certificate warnings).
* **Runtime control**: Enable/disable log collection and set user IDs via the Median JavaScript Bridge.

## Prerequisites

* [ ] A Median app with the JavaScript Bridge enabled
* [ ] Firebase project with Crashlytics enabled
* [ ] `GoogleService-Info.plist` (iOS) and `google-services.json` (Android) from Firebase Console
* [ ] Plugin purchased and enabled in Median App Studio

> [!TIP]
>
> **Test  with our demo page**
>
> We host a ready-made demo page at
>
> that calls the  features through the Median JavaScript Bridge.
> Load it inside your Median app during development, either by setting it
> as your app's website URL in App Studio or by navigating to it from your
> own site, and use it to confirm  works on a real device before
> you add it to your own pages.
>
> The demo page only works inside a Median app with  enabled.
> Opened in a regular mobile or desktop browser, the native features
> won't respond. Remember to switch your app back to your own URL before
> release.

## When to use this plugin

Use Firebase Crashlytics if your app needs to:

| Use case | Example |
| - | - |
| **Crash reporting** | Track and fix native app crashes in real time |
| **WebView errors** | Log WebView console errors to Crashlytics |
| **Android toast errors** | Capture Android toast errors (for example, SSL warnings) |
| **Per-user tracking** | Set a custom user ID to track crash logs per user |
| **Privacy compliance** | Request user opt-in before collecting logs |

## Integration guide

### Enable the plugin

1. **Navigate to Native Plugins**: Open your app in **Median App Studio** and go to the **Native Plugins section**.
2. **Enable Firebase Crashlytics**: Select **Google Firebase Crashlytics** from your list of purchased plugins and enable it.
3. **Configure log collection**: Use the options below to customize which logs are collected.

![Google Firebase Crashlytics plugin enabled in the Native Plugins section of App Studio](https://mintcdn.com/median-co/yvThAkXSLqPa6nzP/images/docs/fff30c1-GoogleCrashlytics_Enable.png?fit=max\&auto=format\&n=yvThAkXSLqPa6nzP\&q=85\&s=f5e4bd4d00ee1dfc0e0cbc21e122a268)

Enable Firebase Crashlytics in App Studio

### Configuration options

| Setting | Description | Recommended |
| - | - | - |
| **requestOptIn** | Enable/disable consent prompt for log collection | Set to true if you need user consent before collecting logs |
| **toastErrorLogsEnabled** | Enable/disable Android toast error collection | Per your needs (Android only) |
| **webErrorLogsEnabled** | Enable/disable WebView console error collection | Per your needs |

Toggle the options as needed, then click **Advanced Mode** for further configuration.

![Crashlytics log collection toggles in the plugin settings](https://mintcdn.com/median-co/dZQPJ_0wlG7WNBTy/images/docs/0fce73d-GoogleCrashlytics_Config.png?fit=max\&auto=format\&n=dZQPJ_0wlG7WNBTy\&q=85\&s=999b9fde90481e58b1e0a77993dbc808)

Enable or disable specific log types

### App configuration

1. **Register your app** in the Firebase Console.

2. **Download** the configuration files:
   1. **Android:** `google-services.json`
   2. **iOS:** `GoogleService-Info.plist`

3. **Upload** **GoogleService-Info.plist (iOS)** and **google-services.json (Android)** in App Studio under **Build & Deploy → Google Services**. You can upload the files from Firebase or copy and paste their contents into App Studio.

For full instructions, refer to the official Firebase setup guides:

* [Android setup](https://firebase.google.com/docs/android/setup)
* [iOS setup](https://firebase.google.com/docs/ios/setup)

> [!TIP]
>
> **Use your AI agent**
>
> Use the Median MCP with your AI agent to enable Firebase Crashlytics and add your Firebase configuration files to your mobile app. See
> [Median MCP server](https://docs.median.co/docs/mcp-server.md) to set it up.

### Finalizing the app build

Once the configuration files are uploaded, save the changes and rebuild your app.

![Uploading Firebase configuration files under Build & Deploy in App Studio](https://mintcdn.com/median-co/7LCOHMhgIef7ewYE/images/docs/673adab78087bd5a5039f6da1ecab94c9b409bde8d0b665e064586218b4a35ff-analytics.gif?s=090fff4304eff74b85f9a76d2ae5c78c)

Upload your GoogleService-Info.plist and google-services.json configurations

### JavaScript Bridge functions

The Median JavaScript Bridge allows you to control Crashlytics at runtime.

#### Enable/disable logs collection

Enable or disable Crashlytics log collection at runtime.

Median JavaScript Bridge

```javascript JavaScript theme={null}
// Enable/disable Crashlytics
median.firebaseCrashlytics.enable(true);
median.firebaseCrashlytics.enable(false);

// WebView error logging
median.firebaseCrashlytics.webErrorLogsEnabled(true);
median.firebaseCrashlytics.webErrorLogsEnabled(false);

// Toast error logging (Android only)
median.firebaseCrashlytics.toastErrorLogsEnabled(true);
median.firebaseCrashlytics.toastErrorLogsEnabled(false);
```

**Parameters:**

| Parameter | Type | Required | Description |
| - | - | - | - |
| `enabled` | `boolean` | Yes | `true` to enable, `false` to disable |

#### Set user ID

Assign a custom user ID to track crash logs per user in Firebase. Persists between app launches; cleared on uninstall/reinstall.

Median JavaScript Bridge

```javascript JavaScript theme={null}
median.firebaseCrashlytics.setUserId("user_123");
```

| Parameter | Type | Required | Description |
| - | - | - | - |
| User ID | `string` | Yes | Your user identifier |

#### Unset user ID

Remove the previously set user ID.

Median JavaScript Bridge

```javascript JavaScript  theme={null}
median.firebaseCrashlytics.unsetUserId(); 
```

## Optional: Request user consent for log collection

To comply with privacy policies or regulations, you can ask users for permission before collecting logs. Enable the permission prompt by setting **requestOptIn** to true in the plugin configuration. Users will see a permission dialog on first app launch after installation.

![Permission dialog asking the user to allow log collection](https://mintcdn.com/median-co/TpSItjrYpkPK-i0N/images/docs/ba4493a-2024-02-14_14-56-43_High_Res_Screenshot.png?fit=max\&auto=format\&n=TpSItjrYpkPK-i0N\&q=85\&s=b95421b3f109c672e0b178c2e1fb569f)

Request user opt-in for log collection

## Testing checklist

Use this checklist to verify Crashlytics is configured and logging as expected:

### Basic functionality

* [ ] Firebase Crashlytics plugin is enabled in App Studio
* [ ] `GoogleService-Info.plist` (iOS) and `google-services.json` (Android) are uploaded in **Build & Deploy → Google Services**
* [ ] App is rebuilt after saving configuration changes
* [ ] `median.firebaseCrashlytics.enable(true)` enables log collection at runtime

### Platform testing

* [ ] `median.firebaseCrashlytics.webErrorLogsEnabled(true/false)` updates WebView error logging behavior
* [ ] `median.firebaseCrashlytics.toastErrorLogsEnabled(true/false)` updates Android toast error logging behavior

### Configuration testing

* [ ] `median.firebaseCrashlytics.setUserId('user_123')` sets a user identifier for crash logs
* [ ] `median.firebaseCrashlytics.unsetUserId()` removes the user identifier
* [ ] If `requestOptIn` is enabled, the permission prompt appears on first app launch after install

### User experience

* [ ] Open [https://median.dev/crashlytics](https://median.dev/crashlytics) inside your app and confirm logs/events are received in Firebase Crashlytics
* [ ] Consent prompt (if used) appears at an appropriate time and copy matches your policy

## Troubleshooting

### Crashlytics functions are undefined or not working

Ensure the JavaScript Bridge is enabled in App Studio and that you call functions after the `median_library_ready()` event. Verify the plugin is enabled and `GoogleService-Info.plist` (iOS) and `google-services.json` (Android) are uploaded in **Build & Deploy → Google Services**.

### Logs do not appear in Firebase Crashlytics

Confirm the app was rebuilt after uploading Google services files and saving plugin settings. Also verify log collection is enabled with `median.firebaseCrashlytics.enable(true)` and that the correct Firebase project files were uploaded for each platform.

### WebView errors are not being captured

Check that `webErrorLogsEnabled` is enabled in plugin settings (and at runtime if you manage it dynamically).

### Android toast errors are not being captured

`toastErrorLogsEnabled` applies to Android only. Ensure it is enabled in settings and test on an Android build.

### User consent prompt does not appear

The prompt only appears when `requestOptIn` is enabled and is shown on first launch post-installation. Reinstall the app to retest first-launch behavior.

> [!NOTE]
>
> **Still having trouble?**
>
> For Firebase Crashlytics issues outside Median, refer to the [Firebase Crashlytics documentation](https://firebase.google.com/docs/crashlytics/get-started).


## Related topics

- [Analytics](https://docs.median.co/docs/analytics.md)
- [Google Firebase Analytics](https://docs.median.co/docs/firebase-analytics.md)
- [Google Services](https://docs.median.co/docs/google-services.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.