Receiving Passbook's .pkpass from URL without Webview


Hi first of all i have to confess i really don't understand how the whole Passbook topic really works. So here's my situation: I have a backend system which creates .pkpass files stores them and creates an URL. When i open this URL in my browser it directly starts to download the pass file. How can i receive or open this file with my ios application?

Thanks in advance.


You can use webservices to get pass data. Webservices can send your pass data in base64(NSString) format and you decode it to get NSData.

The use the data to initiate PKPass Object.

PKPass *pass = [[PKPass alloc] initWithData:passData error:&err];

Once you get PKPass you can use PKAddPassesViewController to show it inside the app. You can find detailed explanation <a href="http://www.raywenderlich.com/20734/beginning-passbook-part-1" rel="nofollow">here</a>.

Note : you can directly download Pass data from the URL using NSUrlConnection and use the downloaded data to create PKPass.


another way..simpler and can be used in mobile web apps as well. write a simple web service to return this pass download URL then parse the json/xml(depends on type of response) in your app(web or native ios) and then invoke the URL in safari.

from native app call [[UIApplication sharedApplication] openURL:passdownloadURL];

I have used it in my project and it works awesome!!


If you host the link to the PKPass item on a website you can check that the page content is really a PKPass item by looking at the mimeType property on HTTPURLResponse, which should be "application/vnd.apple.pkpass". Once you confirm that, download the .pkpass data with an URLRequest and pass the data to the PKPass initializer like this:

var error:NSError? let passBookData = PKPass( data: data, error: &error ) if error != nil { print( "Error opening pkpass file" ) return } let pkPassVC = PKAddPassesViewController( pass: passBookData ) currentVC.present( pkPassVC, animated: true, completion: completion )


  • How to use 'changeMessage' key in pass.json
  • Serializing / Marshalling simple objects in C# to send over network, for an unmanaged C++ applicatio
  • Docker container is killed after ~1 minute
  • Throwing a SoapException does not return a valid SOAP response
  • Dynamic query optimization
  • Jelly bean not calling onPrepareOptionsMenu() when opening the menu for the first time
  • Jquery AJAX-request loading twice
  • Is DateTimeToString in Delphi XE5 doesn't work?
  • EVP reading PEM private key not working properly
  • Find Tables Without Clustered Index but with Primary Keys on a table
  • Fitbit oauth2 public API stopped working. Giving error - Sorry Its not you.. Its us
  • SqlCommand result - Object cannot be cast from dbnull to other types
  • How can I use Angular4 *ngFor to create a data table?
  • Create my own classList object when the browser does not implement it itself
  • Tomcat Replacing VM arguments
  • Optimization of Neural Network input data
  • Enable a text box only when 1 of the radio button is clicked
  • Highlight special word in a TextBox
  • How to order the ties in data so that the previously observed value appears first
  • Holoviews plot not rendered in cell in JupyterLab
  • jQuery - Prevent activation on first click
  • iOS App crash issue `[UIWindow warpPoint:]`
  • Creating http response as a return value for mockito
  • How to fetch asset modification history in hyperledger fabric
  • Is possible having two COM STA instances of the same component?
  • AWS RDS Parameter Group not changing MySQL encoding
  • SQL Server version 612 , 655?
  • Tensorflow Dataset API restore Iterator after completing one epoch
  • How to define something in JavaScript [closed]
  • What Exception is thrown on timeout?
  • Amazon Elastick BeanStalk error: Failed to create the AWS Elastic Beanstalk application version
  • How do I add a mouse over tooltip to an Image using .DrawImage()
  • Google App Engine Datastore: Dealing with eventual consistency
  • How to decleare char *const argv[] in swift [duplicate]
  • ssh remote server login script
  • Grails - How to implement a foreign key relationship not using an id column?
  • Capture SIGFPE from SIMD instruction
  • How to call different template for different category archive page in woocommerce