6

I've seen already some topics on this subject, but havent been able to find the answer:

Safari cannot open .pkpass files that I am sending as email attachemnts

first I thought it might have something do with my settings, but then I found out that I also cant open example .pkpass from this website http://www.tomttb.com/test/pass/full_sample/

Both mine file and the example one have Content Type set to application/vnd.apple.pkpass

On Android I am using PassWallet App, and it is possible to download .pkpass and to add it to the passbook.

Any ideas?

lucafik
  • 295
  • 1
  • 6
  • 18
  • Most likely your certificate is invalid or expired. The example link you provide is failing because of a certificate error. PassWallet does not check the Pass Certificate. Can you post a link to the .pkpass you are having problems with and I can check it? – PassKit Feb 11 '14 at 15:54
  • http://speedy.sh/jmvnE/EventTicket2676929.pkpass Certificate expiration date is December 2014., so that shouldnt be the reason. Its probably invalid. What could be the reason? – lucafik Feb 11 '14 at 16:25

1 Answers1

12

Having looked at your .pkpass bundle, your problem is that your pass.json file contains invalid JSON.

The device console log shows the following when attempting to add the pass:

Feb 12 00:31:58 pfr MobileSafari[236] <Warning>: Invalid data error reading pass
/var/mobile/Applications/AF19C13B-113D-44B9-9067-1228253C82ED/Library/Caches/com.apple.mobilesafari/com.apple.Passbook/5BE44BA0-7E7F-4DFA-92ED-D5E41A984F82.pkpass/pass.json. 
Could not read json from URL file:///var/mobile/Applications/AF19C13B-113D-44B9-9067-1228253C82ED/Library/Caches/com.apple.mobilesafari/com.apple.Passbook/5BE44BA0-7E7F-4DFA-92ED-D5E41A984F82.pkpass/pass.json: 
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" 
(Badly formed object around character 221.) UserInfo=0x148cca010 {NSDebugDescription=Badly formed object around character 221.}

Add a comma after:

"foregroundColor": "rgb(255,111,15)"

and change the key:

"description" : '"totally cool party"',

to:

"description" : "\"totally cool party\"",

Then recompile your .pkpass bundle and you should be good.


** Update **

Your pass is now failing because you have set a string for the formatVersion key when it requires an integer.

Feb 12 11:04:22 pfr MobileSafari[1825] <Warning>: Invalid data error reading pass pass.com.ticketino/2677326. Value for key 'formatVersion' must be of class NSNumber, but is actually of class __NSCFString.
Feb 12 11:04:22 pfr MobileSafari[1825] <Warning>: PassBook Pass download failed: The pass cannot be read because it isn’t valid

Change the key:

"formatVersion": "1",

To:

"formatVersion":1,

Also, it looks like your relevant date is not in an ISO8061 format, which will also cause the pass to be rejected.

To fix, change the relevantDate key to:

"relevantDate" : "2014-02-28T12:00:00Z",

As to how you diagnose these issues, just connect your phone up to a Mac running Xcode and monitor the device console from the Organizer window. If you need more detailed information, you can enable Additional Passbook Logging from the Developer setting menu on the device.


** Update 2 **

Now your pass is failing because the webServiceURL is a secure URL. For production passes your Passbook Web Service MUST be served over https.

If your device is configured for development then you can bypass this by activating the "Allow HTTP Services" option from the Passkit Testing section of the Developer Settings menu.

Also your pass does not contain an authenticationToken key. This is a mandatory key when specifying a webServiceURL (Read the Passbook Web Service Manual!)

Debugging Passbook without access to Xcode is going to be extremely tricky, if not impossible. Would recommend either buying a Mac, or resorting to one of the many ways to Virualise Mac OSX or run Mac OSX on PC Hardware.


** Update 3 **

Feb 12 23:21:36 pfr MobileSafari[225] <Warning>: Invalid data error reading pass pass.com.ticketino/2678239. Unable to parse relevantDate 28-05-2014T12:00:00Z as a date. We expect dates in "W3C date time stamp format", either "Complete date plus hours and minutes" or "Complete date plus hours, minutes and seconds". For example, 1980-05-07T10:30-05:00.
Feb 12 23:21:36 pfr MobileSafari[225] <Warning>: PassBook Pass download failed: The pass cannot be read because it isn’t valid.

Your relevantDate key is still not a valid ISO8601 date!

To fix, change the relevantDate key to:

"relevantDate" : "2014-05-28T12:00:00Z",
PassKit
  • 12,231
  • 5
  • 57
  • 75
  • Thanks. I fixed it, still, it does not seem to open. How do you inspect these files? Here is the new version, maybe you see something else. http://speedy.sh/7zqMt/EventTicket2677326.pkpass – lucafik Feb 11 '14 at 17:48
  • See my updated answer - you're pass is now failing because you have set a string for a field that requires an integer. – PassKit Feb 12 '14 at 03:11
  • Thanks again, I updated according to your instructions. Id be greatful if you could take another look, as there is obviously still another problem. Updated version: http://speedy.sh/JVAaC/EventTicket2677945.pkpass Unfortunately, I do not have Mac available for testing. Is there some way I could view console on device, or anything similar? Thanks a lot. – lucafik Feb 12 '14 at 09:07
  • @update2: I have managed to get access to a Mac this afternoon, but it has not resolved my problems. I am not getting any output in XCode Console when failing to download the file. I have to ask you to take a look at this one finally. http://speedy.sh/cHMds/EventTicket2678239.pkpass I have removed the webServiceURL, because I understand it is not needed for this case. I have used this certificate for signing - http://pokit.org/get/img/648f7a006e1964bb02fb78551e15d3f2.jpg – lucafik Feb 12 '14 at 15:17
  • Not a certificate problem - the issue lies somewhere between the keyboard and the chair! – PassKit Feb 12 '14 at 15:24
  • @update3: Ooops, my bad, sorry. I didnt pay attention to the order of yyyy-MM-dd. But still nothing, sorry. http://speedy.sh/eEdRa/EventTicket2678592.pkpass – lucafik Feb 12 '14 at 15:42
  • @update3: Actually, it works when opened from Mail app. I have tried from Safari, as an attachment, and it doesnt. But from Mail app, it works perfectly. Seems that Safari doesnt recognize it for some reason. – lucafik Feb 12 '14 at 15:54
  • Now it is failing because your signature does not contain a signing date. `Feb 13 00:50:00 pfr MobileSafari[225] : Invalid data error reading pass pass.com.ticketino/2678592. Signature must contain a signing date` How are you signing your pass? Looks like whatever tool or library you are using has not been updated since the signing date requirement was enforced in iOS7. Also, the mail app may display the pass, but it will fail when you try to add it to Passbook. – PassKit Feb 12 '14 at 16:51
  • I see. There was no signing date indeed. Now I am using CmsSigner, adding a signed attribute like on this topic. http://stackoverflow.com/questions/3513162/add-signing-time-to-pkcs7-signed-cms. Is that OK? If yes, there is something else wrong. http://speedy.sh/ENfK9/EventTicket2679960.pkpass – lucafik Feb 13 '14 at 13:34
  • also note that mail app successfully adds the pass to the passbook. maybe that tells you something. – lucafik Feb 13 '14 at 15:43
  • Works fine for me in Safari too. https://dev.anatta.net/w.pkpass. You cannot download direct from something like speedy.sh because the server does not server the pass with the correct headers. You need to serve from a properly configured web server with a MIME Type of `application/vnd.apple.pkpass` - see [this question](http://stackoverflow.com/questions/15383552/how-to-set-mime-type-of-application-vnd-apple-pkpass-in-order-to-share-pass-by-l) for details on how to do that. – PassKit Feb 13 '14 at 16:06
  • that probably means that downloading it from GMail webversion in Safari is never an option? (Thats where I am trying to get it from). Thanks again for all the help! – lucafik Feb 13 '14 at 16:23
  • You're welcome. Can you confirm that the link from my server works for you OK? – PassKit Feb 13 '14 at 16:25
  • This is the way I've used to find out the problem http://geekswithblogs.net/MobileLOB/archive/2012/07/24/debugging-passkit-install-on-ios-simulator.aspx – Hpatoio Mar 18 '16 at 15:04