Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
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
 
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?
 
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?
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.