patrickjane / ut-passes

Access .pkpass passes on Ubuntu Touch
MIT License
4 stars 4 forks source link

Fails to import store pass #8

Closed sergiusens closed 1 year ago

sergiusens commented 1 year ago

This is where I see the failure https://github.com/patrickjane/ut-passes/blob/b223d417a5c8869be0c02be6a9cee46e5df8dff4/src/pkpass.cpp#L417

The primary fields in my pkpass is empty

{
  "passTypeIdentifier": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "formatVersion": 1,
  "serialNumber": "xxxxxxxxxxx    xxxxxxxxxxxxx",
  "description": "Aerolineas Plus Card",
  "organizationName": "Aerolineas Argentinas",
  "teamIdentifier": "xxxxxxxxxxxxxxx",
  "foregroundColor": "rgb(255,255,255)",
  "backgroundColor": "rgb(0,0,0)",
  "labelColor": "rgb(255,255,255)",
  "barcodes": [
    {
      "format": "PKBarcodeFormatQR",
      "message": "xxxxxxxxxxx xxxxxxx|xxxxxxxxx|DNI|xxxxxx|xxxxxx",
      "messageEncoding": "utf-8"
    }
  ],
  "storeCard": {
    "headerFields": [
      {
        "key": "id",
        "label": "N° DE SOCIO",
        "textAlignment": "PKTextAlignmentLeft",
        "value": "xxxxxxxxxx"
      }
    ],
    "primaryFields": [],
    "secondaryFields": [
      {
        "key": "name",
        "label": "NOMBRE",
        "value": "xxxxxxxxx xxxxxxxxxx         "
      },
      {
        "key": "expiration_date",
        "label": "VENCIMIENTO",
        "value": "12/22"
      }
    ],
    "auxiliaryFields": [],
    "backFields": [
      {
        "key": "name",
        "label": "NOMBRE",
        "value": "xxxxxxxxx                         xxxxxxxxxx                                          "
      },
      {
        "key": "id",
        "label": "N° DE SOCIO",
        "value": "xxxxxxxxxxx"
      },
      {
        "key": "expiration_date",
        "label": "FECHA DE VENCIMIENTO",
        "value": "12/22"
      }
    ]
  }
}
patrickjane commented 1 year ago

Hi, thanks for reporting. This indeed a bug, according to the specifications, the fields can be empty. So the check does not make any sense. I will check this on the weekend and make sure the display of passes without primary fields works well, and then publish a fix for the app.

sergiusens commented 1 year ago

FWIW, I edited the file manually (by removing the empty entries) and it seemed to display correctly.Thanks!

patrickjane commented 1 year ago

Hi, sorry for the late update, I just pushed an updated version to the store which should allow empty fields, so this was fixed with #8296786.

My assumption initially was, that while all fields are optional, they should be populated when the property is given. It is not clear from the specification whether or not existing properties in the JSON must have populated fields array or otherwise must be omitted, so I just made it so that either missing property or existing property with empty array will be treated as missing.

Let me know if you encounter further issues.