Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 215
d3p0nit Avatar asked Oct 04 '22 00:10

d3p0nit


2 Answers

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.

like image 109
Vignesh Avatar answered Oct 14 '22 03:10

Vignesh


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!!

like image 20
vikas Avatar answered Oct 14 '22 03:10

vikas