我在iOS应用中集成了存折。我从Apple站点下载了一些通行证,并将passTypeIdentifier更改为我的标识符。我可以使用以下代码将传递添加到我的存折:
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)
}
我可以使用上面的代码添加传递,并且当尝试再次添加相同传递时,也会获得传递中已存在的错误。但我无法访问我添加的通行证。我正在使用以下代码来访问它:
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)
}
我无法在上面的数组中获得任何传递。它总是空的。任何人都可以建议我在这里缺少什么。
由于