pkpassvalidator icon indicating copy to clipboard operation
pkpassvalidator copied to clipboard

Color Validation

Open bencurthoys opened this issue 4 months ago • 0 comments

I just had a pkpass file not work for me in a very annoying way, and eventually I tracked it down to the colour.

My pass generation code used the Name property of a System.Drawing.Color object to set PassGeneratorRequest.BackgroundColor, LabelColor, and ForegroundColor, which worked when the Color object was a custom colour and the name property was the hex representation of the colour, but when it was the constant System.Drawing.Color.Black, and the json looked like this:

image

it just stopped working with the usual "Safari is unable to open this file" message.

I eventually managed to dig out of the log file the error:

Mar 7 14:19:15 iPhone MobileSafari(PassKitCore)[30760] <Error>: Invalid data error reading pass pass.com.monadticketing/b6688f74-f0ad-407f-b5f6-61a829fa7731. Unable to parse color string 'Black'. Mar 7 14:19:15 iPhone MobileSafari(MobileSafariUI)[30760] <Error>: PassBook Pass download failed: Error Domain=PKPassKitErrorDomain Code=1 "(null)"

Would you like me to add to this tool validation of the values of the color fields, and submit a pull request?

bencurthoys avatar Mar 07 '24 16:03 bencurthoys