Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Allow HTML body content #259

Merged
merged 2 commits into from
May 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions PinpointKit/PinpointKit/Sources/Core/FeedbackConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@

/// Encapsulates configuration properties for all feedback to be sent.
public struct FeedbackConfiguration {

/// Encapsulates body content of the feedback submission. Suitable for an email body.
public struct Body {
public var content: String
public var isHTML: Bool

public init(_ content: String, isHTML: Bool = false) {
self.content = content
self.isHTML = isHTML
}
}

/// The value of the default parameter for `title` in the initializer.
public static let DefaultTitle = "Bug Report"
Expand All @@ -21,8 +32,8 @@ public struct FeedbackConfiguration {
/// A short, optional title of the feedback submission. Suitable for an email subject.
public var title: String?

/// An optional plain-text body of the feedback submission. Suitable for an email body.
public var body: String?
/// An optional body of the feedback submission.
public var body: Body?

/// A file name without an extension for the logs text file.
public var logsFileName: String
Expand All @@ -47,7 +58,7 @@ public struct FeedbackConfiguration {
public init(screenshotFileName: String = "Screenshot",
recipients: [String],
title: String? = FeedbackConfiguration.DefaultTitle,
body: String? = nil,
body: Body? = nil,
logsFileName: String = "logs",
additionalInformation: [String: AnyObject]? = nil,
presentationStyle: UIModalPresentationStyle = .fullScreen) {
Expand Down
2 changes: 1 addition & 1 deletion PinpointKit/PinpointKit/Sources/Core/MailSender.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private extension MFMailComposeViewController {
}

if let body = feedback.configuration.body {
setMessageBody(body, isHTML: false)
setMessageBody(body.content, isHTML: body.isHTML)
}

try attach(feedback.screenshot, screenshotFileName: feedback.configuration.screenshotFileName)
Expand Down
2 changes: 1 addition & 1 deletion PinpointKit/PinpointKit/Sources/Core/PinpointKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ open class PinpointKit {
- parameter body: The default body text of the feedback.
- parameter delegate: A delegate that is notified of significant events.
*/
public convenience init(feedbackRecipients: [String], title: String? = FeedbackConfiguration.DefaultTitle, body: String? = nil, delegate: PinpointKitDelegate? = nil) {
public convenience init(feedbackRecipients: [String], title: String? = FeedbackConfiguration.DefaultTitle, body: FeedbackConfiguration.Body? = nil, delegate: PinpointKitDelegate? = nil) {
let feedbackConfiguration = FeedbackConfiguration(recipients: feedbackRecipients, title: title, body: body)
let configuration = Configuration(feedbackConfiguration: feedbackConfiguration)

Expand Down