Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add mutliple pass in apple wallet

My app has a requirement to add multiple passes (a group of the pass) in apple wallet

I have PKAddPassesViewController, and it has a method to add multiple passes but after adding in it, it shows only 1 pass.

//destinationURLs are download file URL
let pkfile1 : Data = try! Data(contentsOf: destinationURL1)
let pkfile2 : Data = try! Data(contentsOf: destinationURL2)
var pkPasses = [PKPass]()
let pass : PKPass = PKPass(data: pkfile1 as Data, error: nil)
let pass1 : PKPass = PKPass(data: pkfile2 as Data, error: nil)
pkPasses.append(pass)
pkPasses.append(pass1)

let vc = PKAddPassesViewController(passes: pkPasses) as PKAddPassesViewController
vc.delegate = self
appDelegate.window?.rootViewController!.present(vc, animated: true, completion: nil)

With this code, I get only 1 proper formatted graph

my screenshot of PKAddPassesViewController's passes

like image 845
SmarterSusheel Avatar asked May 24 '26 22:05

SmarterSusheel


1 Answers

Looking at your code, pass and pass1 contain the same data.

Your comment above explains why you are only seeing one pass, because passes are uniquely indexed by certificate and serial number.

Wallet won't allow 2 passes with the same index, so your second pass is most likely overwriting your first. Use a different serial number when generating your second pass and you will have no problem.

like image 81
PassKit Avatar answered May 27 '26 12:05

PassKit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!