All, I have been reading from Apple documentation and I have found info to show bits of a pass and changing a pass in an app. But is there a way the .pass zip can be stored in XCODE and shown in a pop up view controller ?
I have figured this out, but I doesnt work.
Any advice ??
var pkfile : NSData = NSData(contentsOfFile: "Event.pkpass")!
var pass : PKPass = PKPass(data: pkfile, error: nil)
let vc = PKAddPassesViewController(pass: pass)
self.presentViewController(vc, animated: true, completion: nil)
I have done it like this :
var filePath = NSBundle.mainBundle().pathForResource("Event", ofType:"pkpass")
var pkfile : NSData = NSData(contentsOfFile: filePath!)!
var pass : PKPass = PKPass(data: pkfile, error: nil)
let vc = PKAddPassesViewController(pass: pass) as PKAddPassesViewController
self.presentViewController(vc, animated: true, completion: nil)
and made sure that the pkpass file is set in build Settings/Copy Bundle Resources.
Hope this helps someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With