safari ios cannot open passbook pkpass

19,325

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",
Share:
19,325
lucafik
Author by

lucafik

Updated on June 05, 2022

Comments

  • lucafik
    lucafik about 2 years

    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
    lucafik over 10 years
    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. speedy.sh/7zqMt/EventTicket2677326.pkpass
  • PassKit
    PassKit over 10 years
    See my updated answer - you're pass is now failing because you have set a string for a field that requires an integer.
  • lucafik
    lucafik over 10 years
    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: 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
    lucafik over 10 years
    @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. 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 - pokit.org/get/img/648f7a006e1964bb02fb78551e15d3f2.jpg
  • PassKit
    PassKit over 10 years
    Not a certificate problem - the issue lies somewhere between the keyboard and the chair!
  • lucafik
    lucafik over 10 years
    @update3: Ooops, my bad, sorry. I didnt pay attention to the order of yyyy-MM-dd. But still nothing, sorry. speedy.sh/eEdRa/EventTicket2678592.pkpass
  • lucafik
    lucafik over 10 years
    @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.
  • PassKit
    PassKit over 10 years
    Now it is failing because your signature does not contain a signing date. Feb 13 00:50:00 pfr MobileSafari[225] <Warning>: 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.
  • lucafik
    lucafik over 10 years
    I see. There was no signing date indeed. Now I am using CmsSigner, adding a signed attribute like on this topic. stackoverflow.com/questions/3513162/…. Is that OK? If yes, there is something else wrong. speedy.sh/ENfK9/EventTicket2679960.pkpass
  • lucafik
    lucafik over 10 years
    also note that mail app successfully adds the pass to the passbook. maybe that tells you something.
  • PassKit
    PassKit over 10 years
    Works fine for me in Safari too. 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 for details on how to do that.
  • lucafik
    lucafik over 10 years
    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!
  • PassKit
    PassKit over 10 years
    You're welcome. Can you confirm that the link from my server works for you OK?
  • Hpatoio
    Hpatoio over 8 years
    This is the way I've used to find out the problem geekswithblogs.net/MobileLOB/archive/2012/07/24/…