Bhav
Bhav

Reputation: 2195

Safari cannot download passbook file .pkpass

I've got a link on a web page that should enable users to download a passbook file from a link, however when clicking on the link in Safari on an iPhone, I get the following error message:

Safari cannot download this file.

I have read similar Q&As on here, and the MIME type is set to application/vnd.apple.pkpass. The file can be downloaded on a Windows phone.

Any suggestions on why this is the case and how to resolve this so users can access the passbook file?

The pkpass contains the following files:

icon.png
logo.png
strip.png
manifest.json
pass.json
signature

An example of the manifest.json:

{
  "icon.png": "fa6b59072ae5c8163c903d8c8b5f2e4a45fbd49b",
  "logo.png": "3165c9be22cbf76e2b3118972dabaef8918390f5",
  "strip.png": "5d15c45f543e8088c227fc54a6c01d1f9f0b1db3",
  "pass.json": "0f536b34a6b73a7799aae43ff9861dde45a6dfc6"
}

An example of the pass.json:

{
    "passTypeIdentifier":"pass.com.XXXX.sampleticket",
    "formatVersion":1,
    "serialNumber":"TIC1000000518",
    "description":"XXXX",
    "organizationName":"XXXX",
    "teamIdentifier":"W9XR4FBDD4",
    "logoText":"Dragon Bay",
    "foregroundColor":"rgb(0,0,0)",
    "backgroundColor":"rgb(255,255,0)",
    "labelColor":"rgb(0,0,0)",
    "voided":false,
    "eventTicket":{
        "headerFields":[],
        "primaryFields":[],
        "secondaryFields":[{"key":"activity",
            "label":"11/20/2015 12:00 AM",
            "value":"One Day at the Museum"
            }],
        "auxiliaryFields":[],
        "backFields":[{
            "key":"terms",
            "label":"Terms & Conditions",
            "value":"XXXX"
        },
        {
            "key":"contact",
            "label":"XXXX",
            "value":"XXXX"
        },
        {
            "key":"legal",
            "label":"Legal",
            "value":"XXXX"
        },
        {
            "key":"notes",
            "changeMessage":"%@","label":"Notes","value":""
        },
        {
            "key":"lastUpdated",
            "label":"Last Updated",
            "dateStyle":"PKDateStyleMedium",
            "timeStyle":"PKDateStyleShort",
            "isRelative":false,
            "value":"2016-01-08T19:00Z"
        }]
    },
    "barcode":{
        "format":"PKBarcodeFormatPDF417",
        "message":"1000000518",
        "messageEncoding":"UTF-8",
        "altText":"1000000518"
    },
    "authenticationToken":"0123456789ABCDEF",
    "webServiceURL":"XXXX/passbook.svc"
}

Upvotes: 6

Views: 17050

Answers (7)

Martin
Martin

Reputation: 1

Had the same problem. caused by incorrectly entering the Hex Background color code. Logs does not always tell you the reason, basically any fields that invalid will result in iOS not accepting the pkpasses file.

Upvotes: 0

Quinn Comendant
Quinn Comendant

Reputation: 10516

You can view the cause for the error by viewing iPhone logs in Console.app:

  1. Connect an iPhone to Mac and open Console.app on the Mac.
  2. Select the iPhone in the sidebar in Console.app.
  3. Click the "Start streaming" button in Console.app.
  4. Open the pkpass file on the iPhone (by downloading it in Safari, open it in an email).
  5. Click the "Pause" button in Console.app.
  6. Search in Console.app for:
    • the pass identifier, e.g., pass.com.example.XXXX
    • Pass Viewer
    • Invalid data
    • MobileSafari (if opened in Safari)
    • MobileMail (if opened in Mail)

In my case, I was able to determine the error was caused by my having set the serialNumber value to an integer instead of a string: 🙄

Invalid data error reading pass pass.com.example.XXXX/(null). Value for key 'serialNumber' must be of class NSString, but is actually of class __NSCFNumber.

Upvotes: 2

johnnyb
johnnyb

Reputation: 712

Note - I ran into this problem. The solution for me was picking a different intermediate certificate. Apple has TWO certificates labeled as "WWDR Certificate" in their intermediate certificates on this page: https://www.apple.com/certificateauthority/

However, as of right now, only the one that expires in 2023 actually works for this purpose.

Upvotes: 4

Eric Sellin
Eric Sellin

Reputation: 668

Also check that you're using an up-to-date Apple WWDR intermediate certificate when creating the signature file.

Upvotes: 0

Manfred Wuits
Manfred Wuits

Reputation: 175

i had some other issue causing .pkpass files to be displayed correctly when viewed on my mac, but yielded the same "Safari cannot download this file" - error when trying to view them in iOS.

my source of error was:

  • i was using integer values for the "key" property in the field-definitions (as i'm using a CMS to create those fields)

so, be sure to use only strings as "key" property in the field-definitions

Upvotes: 0

Bhav
Bhav

Reputation: 2195

I changed the webServiceURL to use https as mentioned by @PassKit and the issue was resolved.

Upvotes: 0

Jose
Jose

Reputation: 601

Although this is a bit old this happened to me recently so I'll just leave my solution in case it helps anyone else.

The problem on my side was that I was setting the voided field as a string instead of a boolean, like this: "voided":"false" and was missing the "expirationDate" field.

So doing this fixed the issue:

  ...
  "expirationDate": "2016-06-30T11:59:59Z",
  "voided": false,
  ...

It was tricky and took me a while to figure it out. Hope it helps.

Upvotes: 0

Related Questions