HomeDocumentationAPI Reference
Getting StartedAPI ReferenceHelp CenterVideo Tours

Event Handlers

Covered here are event handlers that you can use to have a block of code executed when a certain action is triggered.

Before Invoking Instabug

This block is executed on the UI thread. Could be used for performing any UI changes before the SDK's UI is shown.

//iOS
IBGBugReporting.WillInvokeHandler = () => 
{
  Console.WriteLine("SDK will be invoked!");
};

//Android
Instabug.SetOnSdkInvokedCallback(new IOnSdkInvokedCallbackClass());

private class IOnSdkInvokedCallbackClass : Java.Lang.Object, IOnSdkInvokedCallback
{
  public void OnSdkInvoked()
  {
    Android.Util.Log.Warn("OnSdkInvoked", "Instabug SDK invoked");
  }
}

Before Sending a Report

This block is executed in the background before sending each report. You can use it to attach logs and extra data to reports.

//iOS
Instabug.WillSendReportHandler = (IBGReport report) =>
{
  report.LogVerbose("Verbos log");
  report.SetUserAttribute("User Attirbute Value", "Key");
  return report;
};

//Android
Instabug.OnReportSubmitHandler(new BeforeSendingReportCallback());

public class BeforeSendingReportCallback : Java.Lang.Object, Report.IOnReportCreatedListener
{
  public void OnReportCreated(Report report)
  {
    report.AddTag("Tag");
    report.LogVerbose("Verbose Log");
    report.AppendToConsoleLogs("Console Log");
    report.SetUserAttribute("User Attribute Value", "Key");
  }
}

After Dismissing Instabug

This block is executed on the UI thread. Could be used for performing any UI changes after the SDK's UI has been dismissed.

//iOS
IBGBugReporting.DidDismissHandler = (IBGDismissType dismissType, IBGReportType reportType) =>
{
    Console.WriteLine("Dismiss Type: " + dismissType + ". Report Type: " +      reportType);
};

//Android
//Not supported yet

What’s Next

Check out our attachments section for details on how to attach your own file. You can even attach a file in one of the handlers above! You can also set custom data, such as a user attribute, or log any data at any time, including inside event handlers.