Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access passes from passbook in my app?

I'm creating app in which I'm adding and showing passes from passbook app of iOS6 to my app. But when I run application on simulator it's showing added passes but when I run same on Device it's showing that my passbook is empty.

I have followed iOS6 tutorial integrating passbook your applications link for creating, adding and showing passes.

for accessing passes I have used following code -

NSArray * passArray = [_passLib passes];
NSLog(@"number of passes in library are: %d",[passArray count]);

//if more tha one pass in library, just use the first one.
if ([passArray count] > 0)
{

    for (int i = 0; i<[passArray count]; i++) 
    {    
    PKPass *onePass = [passArray objectAtIndex:i]; 

    //access general fieldnames
    NSLog(@"%@",[onePass localizedName]);
    NSLog(@"%@",[onePass organizationName]);

    //access a specific field name
    NSLog(@"%@",[onePass localizedValueForFieldKey:@"rewards"]);    
    }
}

Do we need to make any changes if we run app on device to support passbook integration?

like image 940
Trup Avatar asked Dec 24 '12 05:12

Trup


2 Answers

Create AppId which is similar to passTypeIdentifier. For example if your passTypeIdentifier is pass.abc.xyz then your AppId must be com.abc.xyz .While creating provisioning profile make use of this appId and make use of this provisioning profile for your app. Then only you will be able to distinguish passes available in your passbook.

like image 75
Trup Avatar answered Nov 10 '22 03:11

Trup


When you're running an app on the Simulator it basically ignores passTypeIdentifier the passes within the Passbook app were created with. Hence, if the Passbook app on the Simulator has at least one pass, it will show up in your app.

On the other hand, on the Device PKPassLibrary initializing only with the passes that were created with passTypeIdentifier's equal to the ones you have in your provisioning profile and set up in the app's entitlement. Strictly speaking - only with passes you own.

Keep in mind that the App ID you signing your code with should be Enable for Passes on the Provisioning portal as well.

like image 31
Yevhen Dubinin Avatar answered Nov 10 '22 01:11

Yevhen Dubinin