Attach PKPass To Email in App

Discussion in 'iOS Programming' started by newtoiphonesdk, Jan 27, 2013.

  1. newtoiphonesdk macrumors 6502a

    Jul 30, 2010
    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:

        [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:@""];
                [picker setToRecipients:toRecipients];
                 NSURL *url = pkpass.passURL;
         NSData *thepassdata = [NSData dataWithContentsOfURL:url];
                [picker addAttachmentData:thepassdata mimeType:@"application/" 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
  2. ArtOfWarfare macrumors G3


    Nov 26, 2007
    I'm not sure I understand, what is and is not working?

    Is the email composer being presented to the user as it should be?

    If so, is there any attachment at all in the email?
  3. newtoiphonesdk thread starter macrumors 6502a

    Jul 30, 2010
    The composer shows up, but nothing gets attached to it. Apparently there is no way to attach a pkpass to email from within an app.

Share This Page