Your code in it's current state does not make a call to PKAddPassesViewController
to present the pass to the user.
Assuming that the Pass Library is available, the following works with the url you provided in iOS6 & iOS7:
NSData *data = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:kAPIPass]];
if (nil != data) {
PKPass *pass = [[PKPass alloc] initWithData:passData error:&error];
if(error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK"otherButtonTitles:nil];
[alertView show];
} else {
PKAddPassesViewController *pkvc = [[PKAddPassesViewController alloc] initWithPass:pass];
pkvc.delegate = self;
[self presentViewController:pkvc
animated:YES
completion:^{
// Do any cleanup here
}
];
}
}
Alternatively, you could load it asynchronously so as not to block the main thread.
[NSURLConnection sendAsynchronousRequest:_request
queue:_browser
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
if (nil != error) {
// handle error
} else if (nil != data) {
PKPass *pass = [[PKPass alloc] initWithData:passData error:&error];
if(error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK"otherButtonTitles:nil];
[alertView show];
} else {
vc = [[PKAddPassesViewController alloc] initWithPass:pass];
pkvc.delegate = self;
[self presentViewController:pkvc
animated:YES
completion:^{
// Do any cleanup here
}
];
}
}
}];