Attach PKPass To Email in App

Discussion in 'iPhone/iPad Programming' started by newtoiphonesdk, Jan 27, 2013.

  1. macrumors 6502a

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

    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
     
  2. macrumors 603

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    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. thread starter macrumors 6502a

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