Capacitor plugin for Firebase Crashlytics.
npm install https://github.com/josh-m-sharpe/capacitor-firebase-crashlytics.git
npx cap update ios
-
FirebaseCrashlytics.crash()
does not actually crash an Android app or submit anything to Crashlytics. As such, I haven't figured out how to validate the Android use case. This is due to capacitor handling exceptions in plugins differently between Android and iOS. On the Android side, all exceptions in plugin methods are caught. See codes here and here. -
The Android setup process (see below) seems a bit complicated for a plugin. The app-side configuration that is required is somewhat redundant of what is configured within the plugin's
build.gradle
- see here. However, this is the simplest way to getcom.crashlytics.android.Crashlytics
loaded within the plugin that I was able to figure out. Pull Requests or suggestions to improve the situation are welcome.
Load the module:
import { Plugins } from '@capacitor/core';
const {
FirebaseCrashlytics
} = Plugins;
Trigger a crash:
FirebaseCrashlytics.crash();
Log a user:
FirebaseCrashlytics.logUser({
name: this.name,
email: this.email,
id: this.id
})
.then(() => alert(`user logged`))
.catch(err => alert(err.message));
-
Follow the Firebase Crashlytics Get Started guide and put your
google-services.json
here:android/app/google-services.json
-
Make the changes to your project level (
android/build.gradle
) and app level(android/app/build.gradle
) files described in the Firebase Crashlytics docs here. -
Register the plugin in your Activity:
+ import com.jsharpe.capacitorfirebasecrashlytics.FirebaseCrashlytics;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializes the Bridge
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
+ add(FirebaseCrashlytics.class);
}});
}
}
-
Follow Step 1. Put your
GoogleService-Info.plist
here:ios/App/App/GoogleService-Info.plist
-
Skip Step 2. This plugin handles that for you.
-
Follow Step 3 to add a new run script phase.