How to access passes from passbook in my app?

拟墨画扇 提交于 2019-12-22 05:11:51

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/14017551/how-to-access-passes-from-passbook-in-my-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!