I am using PassSlot which creates a Pass on the fly that can be added to passbook. I am trying to get it downloaded to the device to allow attaching to an email. Here is what I have so far:
If I run the code to build the pass, it presents it as expected and works properly, so I know the pass data is good, I just can't figure out correct way to attach that data to the email
Code:
[PassSlot passFromTemplateWithName:@"LoveCouponCards" withValues:values pass:^(PSPass *pass) {
[PassSlot downloadPass:pass pass:^(PSPass *pass) {
PKPass *pkpass = [pass performSelector:@selector(pass)];
NSLog(@"Pass: %@", pkpass);
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSArray *toRecipients = [NSArray arrayWithObject:@"friend@example.com"];
[picker setToRecipients:toRecipients];
NSURL *url = pkpass.passURL;
NSData *thepassdata = [NSData dataWithContentsOfURL:url];
[picker addAttachmentData:thepassdata mimeType:@"application/vnd.apple.pkpass" fileName:@"HI"];
// Fill out the email body text
NSString *emailBody = @"TEST";
[picker setMessageBody:emailBody isHTML:NO];
[self presentViewController:picker animated:YES completion:nil];
}];
}];
If I run the code to build the pass, it presents it as expected and works properly, so I know the pass data is good, I just can't figure out correct way to attach that data to the email