1

I am working on an app, and had a question. My app creates passes on the fly, with the option to add them to your own Passbook, or to email them to another user so they can add it on their passbook. I would like to add an option where a user can click a button, and see if any Passes with the PassID for the app exist in their passbook, and display it. Is it possible for an app to check passbook for existing passes?

Scott Berrevoets
  • 16,921
  • 6
  • 59
  • 80
user717452
  • 33
  • 14
  • 73
  • 149

3 Answers3

1

As long as your app has entitlement for a particular passTypeIdentifier then:

Use the passes method of the PKPassLibrary class to get all passes that your app is entitled to access. Passes are returned in an arbitrary order. If your app displays a list of passes, it should sort them in some meaningful way such as by date.

taken from the Passbook Programming Guide.

PassKit
  • 12,231
  • 5
  • 57
  • 75
  • I read that as well, but all it says is to use the passes method, and then links to the property passes which is an array, but provides no documentation on HOW to use it. – user717452 Jan 30 '13 at 18:51
  • Urrm.. the same as you [use any instance method](http://stackoverflow.com/questions/1053592/objective-c-class-vs-instance-methods) and [loop through an NSArray](http://stackoverflow.com/questions/992901/how-do-i-iterate-over-an-nsarray) – PassKit Jan 31 '13 at 03:29
1

What I would do is to check if the pass exists with passWithPassTypeIdentifier:serialNumber: and then you can open it with openURL if user want to.

I write a quick debug example by looping by the passes:

//get all passes
let passes = PKPassLibrary.init().passes();

//loop is not the best prefer passWithPassTypeIdentifier:serialNumber:
//but it is usefull for debuging
for pass in passes {
  //1) test the pass you want to
  //2) if found, prompt user if they want to open this pass
  //3) if yes, open PassBook with the following command :
  UIApplication.sharedApplication().openURL(pass.passURL)
}
Nicolas Lauquin
  • 1,517
  • 3
  • 14
  • 23
0

Please Go through the below url's to get a better understanding about passbook :

Passbook FAQ

Beginning Passbook in iOS 6: Part 1/2

Beginning Passbook in iOS 6: Part 2/2

CRDave
  • 9,279
  • 5
  • 41
  • 59
Mohammed Shahid
  • 175
  • 1
  • 10
  • I have gone through that thank you very much. I asked a very specific question. View passes that exist in passbook of the app's passtypeid within the app. It seems that is possible using the passes method of the pkpass library but I can't find documentation on how. – user717452 Jan 30 '13 at 10:53