Closed kaanusha closed 7 years ago
Hi @kaanusha Regarding issue 1: Showing multiple barcodes is not supported by Apple's passkit. The reason for having multiple codes in the pass is that you can fall back to an alternative one if it the original format is not supported.
As for issue 2, have you checked, that the created JSON file does indeed contain both barcodes? Are there any messages in the iPhone's console?
Hi @drallgood ,
Thank you for the fast response !!
Yes, I could see all the given barcode formats in JSON file. Please find the attached zip Pass.zip with pkpass and json files.
Kindly help me in finding the issue.
To have the iOS < 9 fallback barcode displayed you need two entries in the pass. One is the Barcodes: entry with multiple barcode definitions. You are setting these. The other is the Barcode: entry with only one definition.
Jpasskit currently does not support setting the barcode: (no s) entry. This could me made available in the PKPass class, possibly with a provision that automatically fills the barcode: entry with one of the supplied barcodes: that are compatible with < iOS 9 devices.
@fabian-hahn You're right. According to Apple's definition, barcode is deprecated: https://developer.apple.com/library/content/documentation/UserExperience/Reference/PassKit_Bundle/Chapters/TopLevel.html#//apple_ref/doc/uid/TP40012026-CH2-SW5
For this to work you have to have set both.
@fabian-hahn As far as I can see that feature is already implemented.
@kaanusha As far as I can see, your pass is missing the barcode
field and only contain barcodes
.
I understand the Apple docs to mean, that we can add two fields: barcode: with one of the old barcode formats and another barcodes: with a list of formats. The old iOS devices will read the barcode: and display. The > iOS 8 devices will choose one of the barcodes: and display the (one) best possible. Currently it is not possible to add both fields with jpasskit.
@fabian-hahn Correct. And jPasskit will automatically select the first supported barcode format from the barcodes
field and return it as barcode
.
I just pushed a few tests that confirm that.
hi @drallgood ,
Thank you !!
As suggested , I have tried with adding barcode field, as below
`List
barcodes.add(barcode);
pass.setBarcodes(barcodes);
PKBarcode barcode1 = new PKBarcode();
barcode1.setFormat(PKBarcodeFormat.PKBarcodeFormatPDF417);
barcode1.setMessageEncoding(Charset.forName("iso-8859-1"));
barcode1.setMessage(request.getParameter("discountCode"));
barcode1.setAltText(request.getParameter("discountCode"));
pass.setBarcode(barcode1);`
I am expecting the IOS version < 9 should display PKBarcodeFormatPDF417 and >9 should display PKBarcodeFormatCode128 barcode.
But in both >9 and <9 IOS versions are showing PKBarcodeFormatPDF417 format only :(
Am i doing any mistake in the code.
@kaanusha Yes. You simply have to add the list of barcodes and jPasskit will automatically make sure that the first supported format is shown on devices prior to iOS 9:
PKBarcode barcode = new PKBarcode();
barcode.setFormat(PKBarcodeFormat.PKBarcodeFormatCode128);
barcode.setMessageEncoding(Charset.forName("iso-8859-1"));
barcode.setMessage(request.getParameter("discountCode"));
barcode.setAltText(request.getParameter("discountCode"));
PKBarcode barcode1 = new PKBarcode();
barcode1.setFormat(PKBarcodeFormat.PKBarcodeFormatPDF417);
barcode1.setMessageEncoding(Charset.forName("iso-8859-1"));
barcode1.setMessage(request.getParameter("discountCode"));
barcode1.setAltText(request.getParameter("discountCode"));
barcodes.add(barcode1);
pass.setBarcodes(barcodes);
@drallgood Thank you very much!!
It is working fine now. :)
Hi, I am few problems with barcodes in PKpass.
Issue 1: I am trying to display more than one barcode on pass. For this I have used the below code:
` List barcodes = new ArrayList();
PKBarcode barcode = new PKBarcode();
barcode.setFormat(PKBarcodeFormat.PKBarcodeFormatCode128);
barcode.setMessageEncoding(Charset.forName("iso-8859-1"));
barcode.setMessage("discountCode");
barcode.setAltText("discountCode");
But, still I am seeing only one barcode on pass. How to show more than one barcode on pass.
Issue 2:
with same code , I am not seeing fallback barcode is working for IOS version 8. 128B is not supported by IOS versions below 9, as a fallback barcode it should display second barcode which is not happening.
Could you please help me on this.