Skip to content

Instantly share code, notes, and snippets.

@debojyoti
Last active January 30, 2019 08:19
Show Gist options
  • Save debojyoti/01132b221bcbdcc7b4fbaa76c8586b57 to your computer and use it in GitHub Desktop.
Save debojyoti/01132b221bcbdcc7b4fbaa76c8586b57 to your computer and use it in GitHub Desktop.

Instabug configuration

Step-1: Add the cordova plugin

ionic cordova plugin add instabug-cordova@8.0.4

Step-2: Configure the android platform files accordingly

2.1) Open YOUR_PROJECT/platforms/android/AndroidManifest.xml Find the application tag and add the android:name attribute value with com.instabug.cordova.plugin.MyApplication

<application 
    android:hardwareAccelerated="true" 
    android:icon="@mipmap/icon" 
    android:label="@string/app_name" 
    android:name="com.instabug.cordova.plugin.MyApplication" 
    android:supportsRtl="true">

2.2) Add the API key to the MyApplication file located at {project_root}/platforms/android/src/com/instabug/cordova/plugin/MyApplication.java

new Instabug.Builder(
        this,
        "INSTABUG_TOKEN",
        InstabugInvocationEvent.SHAKE
).build();

Step-3: Configure app.component.ts accordingly

3.1) Declare a variable called cordova, just below your import statements and above your @Component decorator.

import { Component, ViewChild } from '@angular/core';
import { Nav, Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

...

declare var cordova: any;

@Component({
  templateUrl: 'app.html'
})
export class MyApp {

3.2) In app.components.ts, activate the Instabug plugin, put the following code inside constructor()

this.platform.ready().then(() => {
     
      cordova.plugins.instabug.activate(
        {
            ios: "INSTABUG_TOKEN"
        },
        "shake",
        {
          commentRequired: true,
          colorTheme: "dark"
        },
        function () {
          console.log("Instabug initialized.");
        },
        function (error) {
          console.log("Instabug could not be initialized - " + error);
        }
      );
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment