How to add multi-part Smart Health Cards to Apple Wallet and Health in Swift

89 Views Asked by At

I'm coding in Swift to add Smart Health Cards to Apple Wallet and Health using the guidelines here.

My code works fine with a single part JSON (i.e., shc:/5676290952432060346029243740... snipped for brevity). I am replacing the shc:/ prefix with https://redirect.health.apple.com/SMARTHealthCard/ to use with the Add to Apple Health and Wallet button as described in the link above.

The challenge is when the JSON is in multiple parts, i.e.,

shc:/1/3/567629095243206034602...
shc:/2/3/315057062436201156761...
shc:/3/3/634538347210283310097...

How can I assemble the QR code strings to add multiple vaccines to Apple Wallet and Health using the method described above using one Add to Apple Health and Wallet button? Things I've tried are using the shc:/ prefix on all QR codes in one long string, merging all JSON together and prefixing the entire string with https://redirect.health.apple.com/SMARTHealthCard/ and multiple variations of the above.

1

There are 1 best solutions below

0
On

I found a solution and am posting here in case anyone else needs this information. What works for me is the following format:

https://redirect.health.apple.com/SMARTHealthCard/<QR string 1><QR string 2><QR string 3>

I removed all characters up to the trailing '/' in the QR codes. So all strings contain only numerics. I append all strings into 1 big string of numeric characters in the order of the ordinal number (i.e., 1/3, 2/3, 3/3). Then I pre-pend the redirect URL (https://redirect.health.apple.com/SMARTHealthCard/).