Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pkpass file support #48

Open
TheLastProject opened this issue Oct 24, 2020 · 24 comments · May be fixed by #2038
Open

Pkpass file support #48

TheLastProject opened this issue Oct 24, 2020 · 24 comments · May be fixed by #2038
Labels
common: occasional Affects or can be seen by some users regularly or most users rarely severity: minor Impairs non-critical functionality or suitable workarounds exist state: help wanted I looked into this issue but couldn't solve it quickly type: enhancement New feature or request

Comments

@TheLastProject
Copy link
Member

Issue by jeroen7s
Saturday Sep 07, 2019 at 14:40 GMT
Originally opened as brarcher/loyalty-card-locker#309


.pkpass is a file format specifically for "tickets, passes, coupons or member cards, and also student IDs, loyalty cards"

https://www.file-extension.info/format/pkpass

It's supported by some other popular apps like StoCard, and used by airlines

@TheLastProject
Copy link
Member Author

Comment by brarcher
Thursday Sep 12, 2019 at 06:18 GMT


This app uses the ZXing library for barcode support. Looking at the list of formats supported by that library:

https://github.com/zxing/zxing/#supported-formats

it does not appear that it is supported. If that project supported the format, there may be a case for adding support for it here also. That project is in maintenance mode, though, so I'm not sure how likely it is.

@TheLastProject
Copy link
Member Author

Comment by jeroen7s
Saturday Sep 14, 2019 at 15:42 GMT


Pkpass is not directly a barcode format, but a file format containing info card-ids/private keys instead of a numeric barcode, which would make it outside of the scope of the zxing project

@TheLastProject
Copy link
Member Author

Comment by brarcher
Monday Sep 16, 2019 at 04:17 GMT


Ah. If that is the case, what specifically is the ask? Is it to display the barcode data differently if it is pkpass?

@TheLastProject
Copy link
Member Author

Comment by TheLastProject
Sunday Dec 08, 2019 at 23:22 GMT


I've done a bit of research on this. Pkpass is commonly used for tickets (think plane tickets or CCC). They're actually zip files containing a pass.json file together with some other to us unimportant stuff.

Taking as example https://github.com/keefmoon/Passbook-Example-Code/blob/master/Pass-Example-Generic/Pass-Example-Generic.pkpass

The pass.json file looks as follows:

{
  "passTypeIdentifier" : "pass.keefmoon.example-generic",
  "formatVersion" : 1,
  "teamIdentifier" : "YAXJZJ267E",
  "organizationName" : "Passbook Example Company",
  "serialNumber" : "0000001",
  "description" : "Staff Pass for Employee Number 001",
  "associatedStoreIdentifiers" : [
  	 284971959
  ],
  "locations" : [
  	{"latitude" : 51.50506, "longitude" : -0.01960, "relevantText" : "Company Offices" }
  ],
  "foregroundColor" : "rgb(255, 255, 255)",
  "backgroundColor" : "rgb(90, 90, 90)",
  "labelColor" : "rgb(255, 255, 255)",
  "logoText" : "Company Staff ID",
  "barcode" : {
  		"format" : "PKBarcodeFormatQR",
  		"message" : "0000001",
  		"messageEncoding" : "iso-8859-1",
  		"altText" : "Staff ID 0000001"
   },
  "generic" : {
  	"headerFields" : [
  		{
  			"key" : "staffNumber",
        	"label" : "Staff Number",
        	"value" : "001"
  		}
  	],
    "primaryFields" : [
      {
        "key" : "staffName",
        "label" : "Name",
        "value" : "Peter Brooke"
      }
    ],
    "secondaryFields" : [
      {
        "key" : "telephoneExt",
        "label" : "Extension",
        "value" : "9779"
      },
      {
        "key" : "jobTitle",
        "label" : "Job Title",
        "value" : "Chief Pass Creator"
      }
    ],
    "auxiliaryFields" : [
      {
        "key" : "expiryDate",
        "dateStyle" : "PKDateStyleShort",
        "label" : "Expiry Date",
        "value" : "2013-12-31T00:00-23:59"
      }
    ],
    "backFields" : [
      {
        "key" : "managersName",
        "label" : "Manager's Name",
        "value" : "Paul Bailey"
      },
      {
        "key" : "managersExt",
        "label" : "Manager's Extension",
        "value" : "9673"
      }
    ]
  }
}

While containing a lot more info than a loyalty card, we could most likely just use the description as name and the info in the barcode JSON field to generate the barcode. And maybe somehow put some of the other info in notes after supporting multiline notes first.

So, supporting this would be:

  1. Unzip .pkpass file
  2. Parse relevant info from pass.json
  3. Maybe put some stuff in notes
  4. Discard the rest(?)

Actually not super hard. I think it makes sense to support, although probably only in a basic form. There are other apps like PassAndroid which support this format fully and are better suited for the more complex cases.

@TheLastProject
Copy link
Member Author

Comment by TheLastProject
Monday Dec 09, 2019 at 16:18 GMT


I started with this in #327.

@jeroen7s As you requested this feature, is there any way you could possibly supply me with some pkpass files and screenshots of how they look like in other apps, if you have any you are willing to share? That will help me ensure the best possible result as I know better what to work towards.

@TheLastProject
Copy link
Member Author

Comment by jeroen7s
Monday Dec 09, 2019 at 22:16 GMT


Thanks for working on this, much appreciated. Found an old plane ticket in my Signal conversations you can use.
Here's the File: https://intuxikated.stackstorage.com/s/LbC7LhgNnvF6CPzz
And a screenshot of how it looks in the "StoCard" app on the play store:
signal-2019-09-07-161903

P.s. I wasn't aware there was already an open source app for this, couldn't find "PassBook" at the time, though having it inside the same app as my loyalty cards would be really nice :)

@TheLastProject
Copy link
Member Author

Comment by TheLastProject
Wednesday Dec 11, 2019 at 13:35 GMT


Would it be acceptable if I add your flight ticket as a test case? I assume you're not worried about privacy risks because you already posted it on a public bugtracker, but I'd like to make sure just in case.

@TheLastProject
Copy link
Member Author

Comment by TheLastProject
Wednesday Dec 11, 2019 at 13:45 GMT


On an unrelated note, I absolutely love how the first in-the-wild card I get sent to test with violates the spec every so slightly (incorrect colour code format). Good job, Eurowings!

@TheLastProject
Copy link
Member Author

Comment by jeroen7s
Wednesday Dec 11, 2019 at 13:55 GMT


You can use it for a test-case, however i'd prefer it if you blank out my name tho :D, aside from that you can use it.

@TheLastProject
Copy link
Member Author

Comment by TheLastProject
Saturday Dec 14, 2019 at 19:59 GMT


Just sharing some progress. Still quite a lot of work left, especially because of the whole i18n system.

photo_2019-12-14_20-58-59

@TheLastProject
Copy link
Member Author

Comment by jeroen7s
Monday Dec 16, 2019 at 11:28 GMT


Looks like a great start.
Do you really need the i18n tho?
I think you could add it without translations as a first step and then add translations later?

@TheLastProject
Copy link
Member Author

Comment by TheLastProject
Monday Dec 16, 2019 at 11:29 GMT


Basic i18n is already working, see pull request :)

@TheLastProject
Copy link
Member Author

Comment by jeroen7s
Monday Dec 16, 2019 at 11:30 GMT


cool, nice work 👍

@TheLastProject
Copy link
Member Author

Comment by devurandom
Sunday Feb 02, 2020 at 08:36 GMT


Have a look at https://github.com/ligi/PassAndroid, maybe you can borrow / share some code.

@TheLastProject TheLastProject mentioned this issue Oct 24, 2020
6 tasks
@TheLastProject TheLastProject added the type: enhancement New feature or request label Nov 26, 2020
@TheLastProject TheLastProject added the state: help wanted I looked into this issue but couldn't solve it quickly label Jan 31, 2021
@TheLastProject
Copy link
Member Author

Okay so... looking back at my code now... wow it was not maintainable. I am very glad @brarcher never merged it back in the days.

Basically, this needs a complete rewrite. From scratch.

While #69 can be used as reference, https://github.com/ligi/PassAndroid should be taken as reference much more.

So, it anyone wants to rewrite this (because I still think it is welcome in Catima):

  1. Make a new database table for this, don't try to shoehorn it into the LoyaltyCardDbIds table like I did. The format is just way too different. At most, create an entry in LoyaltyCardDbIds for the basics (so it can be nicely integrated in the rest of the app) with the LoyaltyCardDbIds.ID field being refered to in your PkPass table.
  2. See where to go from there.

I'm sorry for dropping this after all this time, but PassAndroid is a very good app and my previous implementation was just not maintainable. I am willing to help anyone who wants to take this up though!

@TheLastProject TheLastProject added common: occasional Affects or can be seen by some users regularly or most users rarely severity: minor Impairs non-critical functionality or suitable workarounds exist labels Feb 5, 2022
@Altonss
Copy link
Contributor

Altonss commented Aug 20, 2022

I'm sorry for dropping this after all this time, but PassAndroid is a very good app and my previous implementation was just not maintainable. I am willing to help anyone who wants to take this up though!

I recently discovered https://apps.kde.org/fr/itinerary/ which seems to work very fine also for tickets (train/plane...) :)

@e-t-l
Copy link

e-t-l commented Dec 13, 2022

I'm sorry for dropping this after all this time, but PassAndroid is a very good app and my previous implementation was just not maintainable. I am willing to help anyone who wants to take this up though!

I recently discovered https://apps.kde.org/fr/itinerary/ which seems to work very fine also for tickets (train/plane...) :)

Does KDE Itinerary also do Catima stuff like loyalty cards, gift cards, etc? It would be nice to have one app that handles EVERYTHING involving a bar/QR code...

@winkler-winsen
Copy link

I stumbled here looking for pkpass support. I've been using PassAndroid with a similar feature set. There you can also import pkpass files.
How about looking for hints in the code there?
https://github.com/ligi/PassAndroid

@Tragen
Copy link

Tragen commented Jan 29, 2023

I love Catima when I first tested it but then I realized it cannot import pkpass.
Since 3 years it's not possible when I read the issues. What's so complicated?
Everything is described in the first comments.

Unzip .pkpass file
Parse relevant info from pass.json
Maybe put some stuff in notes
Discard the rest(?)

This could be done in a few hours.
I program in C# so I'm not much help with Java.
How can we get this integrated fast? I'm willing so support this with money.

@TheLastProject
Copy link
Member Author

Since 3 years it's not possible when I read the issues. What's so complicated?

The worst complexity is the internationalisation part I suppose. But primarily, the issue is that Catima is a side project and I have a fulltime job and I want to also have time left to spend on other things in my life :)

A lot has changed in Catima since I last put time into this feature though, so it may be easier or harder now, no clue.

This could be done in a few hours.

Given I tried this before (as mentioned in #48 (comment)) I very much doubt it's that simple. Adding a feature in a maintainable way and ensuring stability in a wide range of conditions tends to take a fair share of time too.

(Also, assuming every open issue is "just a few hours" that's still over 100 hours of work. Everyone always considers their own feature most important, so someone is going to be upset no matter what I prioritized and I learned to just prioritize for my own needs)

How can we get this integrated fast?

There is probably no way to get this integrated fast because I still have a huge to-do list (see all the open Pull Requests, it'd be rude to ignore those who already submitted code) and I kinda burned myself out over Hacktoberfest (I was spending pretty much all my spare time every single day on Catima during it).

The fastest way is probably for someone else to work on this, but I have seen that recently a lot of people are interested in this feature again (I haven't heard any request for this feature in years, it is mostly the last few weeks after Catima got mentioned in C't so it mostly seems to be a popular feature in Germany) so I may pick it up after I've finally gotten to dealing with the currently open pull requests but that'll take a while still.

@Tycho-S
Copy link

Tycho-S commented Mar 8, 2023

It would be great to have this.. Pkpass is pretty much an industry standard now, and because Android doesn't have a competing standard, I see companies gravitating more towards it. Airline tickets, event tickets etc. I'm in Spain by the way, not Germany but it's used a lot here too.

Right now I use StoCard but it's a horrible datamining app, I didn't know about PassAndroid, I will try it instead. But if Catima could do it that would be so great :) Not trying to push because I understand that your hands are full :) But I just wanted to explain the desire for this feature.

PS: Thanks for all your work on Catima, it's a really nice app.

@obfusk
Copy link
Contributor

obfusk commented Aug 30, 2023

I'm hoping to look into supporting this sometime soon.

@obfusk obfusk mentioned this issue Oct 15, 2023
49 tasks
@Korb
Copy link

Korb commented Jul 4, 2024

For the sake of completeness, it is worth mentioning that this standard was developed with the support of Apple Inc., and the main documentation is located at https://developer.apple.com/documentation/passkit_apple_pay_and_wallet/pkpass

@TheLastProject
Copy link
Member Author

TheLastProject commented Aug 3, 2024

I'm trying to take another stab at this in my spare time. I'm having some trouble hunting down good test cases though. So if you have any .pkpass files, especially ones with localization, that you're okay with sharing that would be great. It would be even greater if I'd be allowed to include your .pkpass files in the Catima git repository as unit tests. Feel free to censor some parts (but please do tell me what you censored so I know the manifest correctly won't match and what to look at if things behave weird).

If you have some passes you're willing to share with me but not post publicly, feel free to email the email on my GitHub profile :) Thanks!

Edit: Thank you GitHub and Fediverse users! I think I have enough passes with a wide enough variety to be able to implement this well :)

@TheLastProject TheLastProject linked a pull request Aug 11, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common: occasional Affects or can be seen by some users regularly or most users rarely severity: minor Impairs non-critical functionality or suitable workarounds exist state: help wanted I looked into this issue but couldn't solve it quickly type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants