3
votes

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

1
can you try to slide left or right to see if the 2 passes are present? - Hichem BOUSSETTA
I already check but i didn't get any other pass or tickets. - SmarterSusheel
what makes a pass unique is the pass type identifier and serial number fields. can you check if you passes have the same (pass type id + S/N)? - Hichem BOUSSETTA
@HichemBOUSSETTA, we have a different pass/tickets from our own app but pass type identifier and serial number is the same because ticket/pass generated from our app - SmarterSusheel
you need to use a different serial number for each pass you generate, otherwise they will be considered the same. - Hichem BOUSSETTA

1 Answers

1
votes

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.