6

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?

Trup
  • 635
  • 5
  • 17

2 Answers2

8

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.

Trup
  • 635
  • 5
  • 17
  • 1
    You probably meant that if AppIdentifier is com.abc.xyz, then PassTypeIdentifier should be pass.com.abc.xyz Correct me if I am wrong – AzaFromKaza Sep 06 '19 at 09:54
4

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.

Yevhen Dubinin
  • 4,657
  • 3
  • 34
  • 57
  • Thanks for your answer. But still I'm not able to solve the problem. I'm not getting what exact mean to - "passes that were created with passTypeIdentifier's equal to the ones you have in your provisioning profile". Can you please tell in detail? – Trup Jan 16 '13 at 11:00
  • Hi, first of all you cannot access passes that were created under other developers account. Only passes that created by you are accessible on device with PKPassLibrary methods. Also, the Provision profiles (both dev and ad-hoc) should be created with App-Id which does not have '*' in its name. – Yevhen Dubinin Sep 02 '13 at 21:50