Custom Fields

The Buglife bug reporter UI can be configured to present custom input fields. There are two types of available input fields to choose from: Text input fields and Picker input fields.

To configure custom input fields, initialize one or more instances of LIFETextInputField and/or LIFEPickerInputField, and configure Buglife with them by setting the Buglife.inputFields property.

By default, custom input fields are not required. If you’d like to prevent users from submitting blank values for a given input field, set the required property on any input field.

Text input fields

The LIFETextInputField class can be used to configure text entry fields, and can be single- or multi-line. You may choose to configure custom text input fields to collect information such as steps to reproduce, or information about a user.

/// Swift
let stepsField = LIFETextInputField(attributeName: "Steps")
stepsField.isMultiline = true
Buglife.shared().inputFields = [stepsField]
/// Objective-C
LIFETextInputField *stepsField = [[LIFETextInputField alloc] initWithAttributeName:@"Steps"];
stepsField.multiline = YES;
[Buglife sharedBuglife].inputFields = @[stepsField];

The Summary input field

By default, the Buglife bug reporter is configured with the Summary input field (typically labeled with What happened?), which is a special instance of type LIFETextInputField. To use the special Summary field with custom fields, grab an instance of it using LIFETextInputField‘s summaryInputField factory method.

The following is equivalent to simply using the default Buglife configuration:

/// Swift
let summaryField = LIFETextInputField.summary()
Buglife.shared().inputFields = [summaryField]
/// Objective-C
LIFETextInputField *summaryField = [LIFETextInputField summaryInputField];
[Buglife sharedBuglife].inputFields = @[summaryField];

The user email input field

You may also present a field to collect user email addresses using LIFETextInputField’s userEmailInputField factory method. Values entered by the user for this field are persisted across application launches.

You can programmatically configure the default value for this field using Buglife.setUserEmail(). If the user changes this value during the bug report flow, then the value you provided will be overridden with the user-inputted value, including for subsequent application launches.

Picker input fields

The LIFEPickerInputField class can be used to surface pickers, which allow users to select a single value from an array of options.

/// Swift
let field = LIFEPickerInputField(attributeName: "Area")
field.setOptions(["Music library", "Audio player", "Downloads", "Search"])
Buglife.shared().inputFields = [field]
/// Objective-C
LIFEPickerInputField *field = [[LIFEPickerInputField alloc] initWithAttributeName:@"Area"];
[field setOptions:@[@"Music library", @"Audio player", @"Downloads", @"Search"]];
[Buglife sharedBuglife].inputFields = @[field];

Default values

You can configure default values for both text & picker input fields using Buglife.setStringValue(_:forAttribute:). For example, you can use this to dynamically configure the default value for a field when the user switches screens in your app.

The attribute name should equal one of your input field names; If setting an attribute for a picker, the attribute value should equal one of that picker’s options.

The following code will select the Audio player option by default for the picker example shown above.

/// Objective-C
[[Buglife sharedBuglife] setStringValue:@"Audio player" forAttribute:@"Area"];
/// Swift
Buglife.shared().setStringValue("Audio player", forAttribute: "Area")


The following example configures the bug reporter UI with 3 input fields: a required Summary field, a Reproducibility picker, and a multi-line Steps field:

/// Swift
let summaryField = LIFETextInputField.summary()
summaryField.isRequired = true
let reproducibilityField = LIFEPickerInputField(attributeName: "Reproducibility")
reproducibilityField.setOptions(["Always", "Sometimes", "Rarely"])
let stepsField = LIFETextInputField(attributeName: "Steps to reproduce")
stepsField.isMultiline = true
Buglife.shared().inputFields = [summaryField, reproducibilityField, stepsField]
/// Objective-C
LIFETextInputField *summaryField = [LIFETextInputField summaryInputField];
summaryField.required = YES;
LIFEPickerInputField *reproducibilityField = [[LIFEPickerInputField alloc] initWithAttributeName:@"Reproducibility"];
[reproducibilityField setOptions:@[@"Always", @"Sometimes", @"Rarely"]];
LIFETextInputField *stepsField = [[LIFETextInputField alloc] initWithAttributeName:@"Steps to reproduce"];
    stepsField.multiline = YES;
[Buglife sharedBuglife].inputFields = @[summaryField, reproducibilityField, stepsField];