I have integrated passbook in my iOS app. I have downloaded some passes from Apple site and changed the passTypeIdentifier to my identifier. I am able to add passes to my passbook using following code:
let data:NSData = NSData(contentsOfFile:path)!
var error1:NSError?
let pass = PKPass.init(data: data, error: &error1)
if(passLib.containsPass(pass)){
let passArray = passLib.passes()
sharedUtility.sharedInstance.showAlertUIViewController("Pass Exists", message: String(passArray.count) + "The pass you are trying to add to Passbook is already present.", buttonTitle: "OK", controller: self)
}
else{
let vc:PKAddPassesViewController = PKAddPassesViewController(pass: pass) as PKAddPassesViewController
self.presentViewController(vc, animated: true, completion: nil)
}
I am able to add passes using above code and also get error that pass already exists in passbook when trying to add same pass again. But I am not able to access the passes added by me. I am using following code to access it:
let passArray = passLib.passes()
if(passArray.count>0){
let onePass:PKPass = passArray[0]
print(onePass)
sharedUtility.sharedInstance.showAlertUIViewController("Pass Found", message: String(passArray.count) + " Found", buttonTitle: "OK", controller: self)
}
else{
sharedUtility.sharedInstance.showAlertUIViewController("Pass Not Found", message: String(passArray.count) + " Found", buttonTitle: "OK", controller: self)
}
I am not able to get any pass in above array. It is always empty. Can anyone suggest me what I am missing here.
Thanks