Embed URL in barcode in Apple passes

423 Views Asked by At

Is it possible to embed URL in Apple passes in such a way that when scanned, they redirect to that URL? I want to POST information to an API when the barcode/QR code gets scanned.

1

There are 1 best solutions below

0
On

I have replicated this requirement and I am succesfully able to embed an URL inside the barcode of an Apple Wallet Pass. Below are the steps I followed,

So all you have to do is just enter the url value as a string,

  1. Encode exactly the text of the URL in the barcode: "https://www.passsource.com/info/". Include the protocol ("http://", here) to ensure it is recognized as a URL.

In my Java code, I am using a open source Java library to generate the Apple wallet pass which is Jpasskit. I have entered the set message with the url string value and encoded as below,

barcode.setMessage("https://www.passsource.com/info/");
barcode.setMessageEncoding(Charset.forName("utf-8"));
List<PKBarcode> barcodeList = new ArrayList<PKBarcode>();
barcodeList.add(barcode);
pass.setBarcodes(barcodeList);
  1. After generating the Apple Pass, the bar code will be diplayed similar to the below image in the bottom of the pass

enter image description here

  1. Scan the barcode using a qr code reader and it will display the message as below asking permission to open the URL in a browser,

enter image description here

  1. Once you click "Open in Browser" option, it will neatly opened in the mobile browser sunch as chrome.

enter image description here