BOM couldn't extract the archive. exception in initialising pkpass with the pass url which is generated using passkit

StackOverflow https://stackoverflow.com/questions/20990140

Вопрос

When trying to display the pass within my app using the following code, I am getting the error "BOM could not extract the archive. PKpass signature missing exception constantly". Please help me to get ride of this exception.

NSURL *url = [NSURL URLWithString:urlString];
NSData *passData = [NSData dataWithContentsOfUrl: url];
PKPass *pass = [[PKPass alloc] initWithData:passData error:&err];

I am using Xcode 5.2 for the development and mashape to generate passes.

Это было полезно?

Решение

Assuming that your question relates to the PassKit API on Mashape, you need to append .pkpass to the end to the URL that is returned from the issue request.

The raw URL delivers a contextual response depending on whether or not it is being called from a Passbook capable browser (try accessing the URL via Firefox on on an Android device).

In your case, [NSData dataWithContentsOfUrl: url]; is receiving a HTML response which is causing PKPass to complain that it cannot extract the archive, and subsequently cannot find a signature.

Appending .pkpass to the URL forces the API to deliver the raw .pkpass bundle.

So if your response is:

{
  "success"        : true,
  "serial"         : "7114189133818574",
  "url"            : "https://r.pass.is/b93NuXKuX1Tj",
  "passbookSerial" : "1fBHoUz9zOOk0yGs47wDC",
  "shareID"        : "2HcFlmRLblKdQZsa4W9zkc",
  "uniqueID"       : "b93NuXKuX1Tj"
}

urlString should be https://r.pass.is/b93NuXKuX1Tj.pkpass.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top