Attachments
In addition to the screenshot & console logs (which are included automatically), your application can also include custom attachments with each bug report.
To include custom attachments with your bug reports:
- Adopt the
BuglifeDelegate
protocol, and set theBuglife.delegate
property. - Implement
buglife(_:handleAttachmentRequestWithCompletionHandler:)
in your application code. Within your implementation of the above delegate method, add your attachments using
addAttachmentWithData(_:, type:, filename:)
At the end of your implementation of the above delegate method, call the completion handler.
Example:
func buglife(_ buglife: Buglife, handleAttachmentRequestWithCompletionHandler completionHandler: @escaping () -> Swift.Void) {
let myTextFileData: Data = // data from MyTextFile.txt
do {
try buglife.addAttachmentWithData(myTextFileData,
type: LIFEAttachmentTypeIdentifierText,
filename: "MyTextFileData.txt")
} catch {
print("Error attaching data: (error)")
}
completionHandler()
}
- (void)buglife:(Buglife *)buglife handleAttachmentRequestWithCompletionHandler:(void (^)())completionHandler
{
NSData *myTextFileData = // data from MyTextFile.txt
NSError *error;
BOOL success = [buglife addAttachmentWithData:myTextFileData
type:LIFEAttachmentTypeIdentifierText
filename:@"MyTextFile.txt"
error:&error];
if (!success) {
NSLog(@"Error attaching data: %@", error);
}
completionHandler();
}
Attachments may be added from any thread. The completion handler may also be called from any thread; however, if the completion handler is not called within several seconds, a warning will be logged & subsequent attachments will be ignored.
Custom attachments carry several limitations:
- You may attach up to 10 files per bug report.
- The total size of all attachments must not exceed 3 MB.
- The permitted attachment types are text, JSON, and SQLite, with more types to be added in upcoming releases. (Got a request? Let us know!)