Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crashlytics with Ionic 3 app

I have implemented Firebase plugin with ionic 3 app. It is working fine. Could you tell me how can I use Crashlytics with this plugin? According to the doc it seems for the native apps. So how can we do it with Ionic 3?

There is a plugin cordova-fabric-plugin which we can use with ionic apps. But it seems we don't need it anymore since this note on the native apps doc: Any guidance please?

Note: If you're upgrading from Fabric Crashlytics, remove the Fabric API key from your AndroidManifest.xml. Delete the key's meta-data tag, which should have io.fabric.ApiKey and the API key.

like image 930
Sampath Avatar asked Aug 28 '26 20:08

Sampath


1 Answers

In theory you should setup the FabricPlugin just as described. (the versions required of the firebase are lower than the once included)

To setup on ionic I recommend to read the following issue: https://github.com/sarriaroman/FabricPlugin/issues/70

Short Version: Create then a custom error handler

{provide: ErrorHandler, useClass: FabricErrorHandler},

and then your custom Error Handler

import {Injectable} from "@angular/core";
import {IonicErrorHandler } from 'ionic-angular';
import * as stacktrace from 'stacktrace-js';

@Injectable()
export class FabricErrorHandler extends IonicErrorHandler {
    constructor (public analytics: Analytics) {
        super();
    }

    handleError(error) {
        window.fabric.Crashlytics.addLog('crash triggered');
        stacktrace.get().then(
            trace => window.fabric.Crashlytics.endNonFatalCrash(error.message, trace)
        );

        super.handleError(error);
    }
}
like image 75
wodka Avatar answered Sep 02 '26 22:09

wodka