i would like to be able to save and email a pdf of a consent form from research kit. Currently, I have the following code to generate the pdf
let signatureResult : ORKConsentSignatureResult = taskViewController.result.stepResult(forStepIdentifier: "ConsentReviewStep")?.firstResult as! ORKConsentSignatureResult
let consentDocument = ConsentDocument.copy() as! ORKConsentDocument
signatureResult.apply(to: consentDocument)
consentDocument.makePDF { (data, error) -> Void in
var documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
documentsPath.append("consent.pef")
var documentsURL = NSURL.fileURL(withPath: documentsPath)
try? data?.write(to: documentsURL, options: [.atomic])
}
This first fails with error Terminating app due to uncaught exception 'NSObjectNotAvailableException', reason: 'Signature title is missing'
Not sure where to go from here to get this part working, before moving on to the mailing function.