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 here.
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 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