Allow customizable attachments to feedback

- New `BITHockeyAttachment` class, which `BITCrashAttachment` is now a subclass of
- Can also be used in `prepareWithItems:` for BITFeedbackComposeViewController
- Allows to set a custom filename and content-type for attachments that can be used with crash reports and with feedback
This commit is contained in:
Andreas Linde
2014-06-21 16:23:55 +02:00
parent 5fc0014385
commit cae1226b38
14 changed files with 228 additions and 74 deletions

View File

@@ -43,6 +43,7 @@
#import "BITHockeyHelper.h"
#import "BITImageAnnotationViewController.h"
#import "BITHockeyAttachment.h"
@interface BITFeedbackComposeViewController () <BITFeedbackUserDataDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIActionSheetDelegate, BITImageAnnotationDelegate> {
@@ -114,6 +115,22 @@
BITFeedbackMessageAttachment *attachment = [BITFeedbackMessageAttachment attachmentWithData:item contentType:@"application/octet-stream"];
attachment.originalFilename = [NSString stringWithFormat:@"Attachment_%li.data", (unsigned long)[self.attachments count]];
[self.attachments addObject:attachment];
} else if ([item isKindOfClass:[BITHockeyAttachment class]]) {
BITHockeyAttachment *sourceAttachment = (BITHockeyAttachment *)item;
if (!sourceAttachment.hockeyAttachmentData) {
BITHockeyLog(@"BITHockeyAttachment instance doesn't contain any data.");
continue;
}
NSString *filename = [NSString stringWithFormat:@"Attachment_%li.data", (unsigned long)[self.attachments count]];
if (sourceAttachment.filename) {
filename = sourceAttachment.filename;
}
BITFeedbackMessageAttachment *attachment = [BITFeedbackMessageAttachment attachmentWithData:sourceAttachment.hockeyAttachmentData contentType:sourceAttachment.contentType];
attachment.originalFilename = filename;
[self.attachments addObject:attachment];
} else {
BITHockeyLog(@"Unknown item type %@", item);
}