SmarterSusheel
SmarterSusheel

Reputation: 169

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

Upvotes: 3

Views: 2161

Answers (1)

PassKit
PassKit

Reputation: 12581

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.

Upvotes: 1

Related Questions