Customizations

iOS SDK

πŸ”§ SDK

Initialize the SDK

To initialize the BugBattle SDK, you need to add the following code to the end of the applicationDidFinishLaunchingWithOptions delegate.

Swift
Objective-C
Swift
BugBattle.initWithToken("YOUR-API-KEY", andActivationMethod: SHAKE)
Objective-C
[BugBattle initWithToken: @"YOUR-API-KEY" andActivationMethod: SHAKE];

Your API key can be found in the project settings within BugBattle. Possible values for the activation method are NONE, SHAKE and THREE_FINGER_DOUBLE_TAB.

BugBattle.NONE: No automatic activation.

BugBattle.SHAKE: Activation on device shake.

BugBattle.THREE_FINGER_DOUBLE_TAB: Activation on double tapping with three fingers.

BugBattle.SCREENSHOT: Activation when user performs a screenshot trigger.

It's also possible to initialize the SDK with multiple activation methods.

[BugBattle initWithToken: @"YOUR_API_KEY" andActivationMethods: @[@(THREE_FINGER_DOUBLE_TAB), @(SHAKE), @(SCREENSHOT)]];

Manually initiate the bug reporting flow

Some situations require more control about the activation of the bug reporting flow. By calling the startBugReporting method, you can simply start the flow manually. In order to also prevent the shake gesture, just initialize the Bugbattle SDK with the activation method NONE.

Swift
Objective-C
Swift
BugBattle.startBugReporting()
Objective-C
[BugBattle startBugReporting];

Attach a custom screenshot

Starts the bug reporting with a custom screenshot attached.

Swift
Objective-C
Swift
BugBattle.startBugReporting(withScreenshot: awesomeImage)
Objective-C
[BugBattle startBugReportingWithScreenshot: awesomeImage];

Customer email address

Sets the customer's email address.

Swift
Objective-C
Swift
BugBattle.setCustomerEmail("[email protected]")
Objective-C
[BugBattle setCustomerEmail: @"[email protected]"];

Attach custom data

Sometimes you need to attach custom data to bug reports in order to solve them more quickly. Any simple dictionary can be attached.

Swift
Objective-C
Swift
BugBattle.attachCustomData(["aKey": "containsAwesomeData"])
Objective-C
[BugBattle attachCustomData: @{@"aKey": @"containsAwesomeData"}];

πŸŽ₯ Replays

Bugbattle Replays offer session replays of the last 60 seconds prior to a bug report. This allows you to gain a better understanding of how a bug occurred. The great thing is that we don't require any further user permissions for the replays.

Swift
Objective-C
Swift
BugBattle.enableReplays(true)
Objective-C
[BugBattle enableReplays: true];

🌎 Network logging

Bugbattle allows you to monitor all network requests for a better understanding of what's happening within your web-apps & websites. The feature is currently in BETA. Please enable network logging by calling the following method right after initializing the SDK.

Swift
Objective-C
Swift
BugBattle.startNetworkRecording();
Objective-C
[BugBattle startNetworkRecording];

In certain circumstances you might need to pass an NSURLSessionConfiguration in order for BugBattle to be able to log the network requests.

Swift
Objective-C
Swift
BugBattle.startNetworkRecording(for: sessionConfiguration)
Objective-C
[BugBattle startNetworkRecordingForSessionConfiguration: sessionConfiguration];
​

AFNetworking

To enable network logging for AFNetworking, create and use the following class.

// BBAFURLSessionManager.h
#import <AFNetworking/AFNetworking.h>
​
@interface BBAFURLSessionManager : AFHTTPSessionManager
​
@end
​
// BBAFURLSessionManager.m
#import "BBAFURLSessionManager.h"
#import <BugBattle/BugBattle.h>
​
@implementation BBAFURLSessionManager
​
- (instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)configuration {
[BugBattle startNetworkRecordingForSessionConfiguration: configuration];
return [super initWithSessionConfiguration:configuration];
}
​
@end

Example usage for the BBAFURLSessionManager.

// Use the BBAFURLSessionManager for all further requests
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
BBAFURLSessionManager *manager = [[BBAFURLSessionManager alloc] initWithSessionConfiguration: configuration];
​
[manager GET: @"https://www.example.org/get" parameters:nil headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"Error: %@", error);
}];

Alamofire

To enable network logging for Alamofire, create and use the following class.

import Alamofire
import BugBattle
​
class BBSessionManager: Alamofire.Session {
static let sharedManager: BBSessionManager = {
let configuration = URLSessionConfiguration.default
BugBattle.startNetworkRecording(for: configuration)
let manager = BBSessionManager(configuration: configuration)
return manager
}()
}

Example usage for the BBSessionManager.

BBSessionManager.sharedManager.request("https://www.sample.org/get").response { response in
debugPrint(response)
}

πŸ’¬ Translations

Bugbattle automatically uses the system language (if a translation is available) as default SDK language. It's possible to force a language by adding the following method call.

Swift
Objective-C
Swift
BugBattle.setLanguage("de")
Objective-C
[BugBattle setLanguage: @"de"];

Available translations: en, de, fr, it, es We are happy to add more languages based on your requests!

πŸ•΅οΈ Privacy policy

Enable privacy policy check

Enables the privacy policy check within the bug reporting flow. With this option set to true, users must accept the privacy policy in order to send a bug report.

Swift
Objective-C
Swift
BugBattle.enablePrivacyPolicy(true)
Objective-C
[BugBattle enablePrivacyPolicy: true];

Privacy policy url

Sets the privacy policy url. This is especially handy if you have any special requirements regarding the privacy policy. The default url is set to the Bugbattle privacy policy.

Swift
Objective-C
Swift
BugBattle.setPrivacyPolicyUrl("https://awesomeproject.com/privacypolicy")
Objective-C
[BugBattle setPrivacyPolicyUrl: @"https://awesomeproject.com/privacypolicy"];

🎨 Styling

Sets the NavigationBar tint color. Accepts an UIColor.

Swift
Objective-C
Swift
BugBattle.setNavigationBarTint(UIColor.blue)
Objective-C
[BugBattle setNavigationBarTint: UIColor.blueColor];

Sets the Navigation tint color. Accepts an UIColor.

Swift
Objective-C
Swift
BugBattle.setNavigationTint(UIColor.white)
Objective-C
[BugBattle setNavigationTint: UIColor.whiteColor];

Sets the NavigationBarTitle color. Accepts an UIColor.

Swift
Objective-C
Swift
BugBattle.setNavigationBarTitleColor(UIColor.white)
Objective-C
[BugBattle setNavigationBarTitleColor: UIColor.whiteColor];

πŸ–₯ Self-Hosted

API url

Sets the API url to your internal Bugbattle server. Please make sure that the server is reachable within the network.

Swift
Objective-C
Swift
BugBattle.setApiUrl("https://internalbugbattle.server")
Objective-C
[BugBattle setApiUrl: @"https://internalbugbattle.server"];