Giter VIP home page Giter VIP logo

capacitor-firebase-crashlytics's Introduction

capacitor-firebase-crashlytics

Capacitor plugin for Firebase Crashlytics.

npm install https://github.com/josh-m-sharpe/capacitor-firebase-crashlytics.git
npx cap update ios

Known Issues / Contribution Ideas

  1. 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.

  2. 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 get com.crashlytics.android.Crashlytics loaded within the plugin that I was able to figure out. Pull Requests or suggestions to improve the situation are welcome.

Usage

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));

Android setup

  1. Follow the Firebase Crashlytics Get Started guide and put your google-services.json here: android/app/google-services.json

  2. 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.

  3. 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);
      }});
    }
  }

iOS setup

  1. Open the Firebase Crashlytics Get Started guide

  2. Follow Step 1. Put your GoogleService-Info.plist here: ios/App/App/GoogleService-Info.plist

  3. Skip Step 2. This plugin handles that for you.

  4. Follow Step 3 to add a new run script phase.

capacitor-firebase-crashlytics's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.