3

I am building a share extension for iOS and would like to accept Passbook passes. I have the share extension working in that:

NSItemProvider *itemProvider = inputItem.attachments.firstObject;
[itemProvider hasItemConformingToTypeIdentifier:@"com.apple.pkpass"];

returns true. However, I'm lost at attempting to load this item. I've tried coercing it to NSData using this and other types:

[itemProvider loadItemForTypeIdentifier:@"com.apple.pkpass" options:nil completionHandler:^(NSdata *item, NSError *error) {
    NSLog(@"%@", item);
}];

However, none work. Does anybody know how to use Passbook passes in a share extension? I preferably would like an NSData object.

bdjett
  • 514
  • 5
  • 9

1 Answers1

4

Get the returned data as "id" type first, then create your PKPass object by "initWithData" with your returned data. You don't need to convert it to NSData.

Remember to import Passkit.

Zane
  • 41
  • 1