ios - PKPassLibrary containsPass return wrong value -
i add pkpass library through pkaddpassesviewcontroller
. pass visible in passbook app.
the following code called:
nsdata *data = [nsdata datawithcontentsoffile:filepath]; nserror *error; //init pass object data pkpass *pass = [[pkpass alloc] initwithdata:data error:&error]; if([self.passbooklibrary containspass:pass]) {
passbooklibrary not nil.
containspass returns yes on ios7
containspass returns no on ios6
there 2 types of pkpass. pklocalpass , pkremotepass. above created pkpass pklocalpass. check works pkremotepass. can obtain function:
- (pkpass *)passfromlibraryfrompkpass:(pkpass *)pass { if (system_version_less_than(@"7.0")) { pkpass *librarypass = [self.passbooklibrary passwithpasstypeidentifier:pass.passtypeidentifier serialnumber:pass.serialnumber]; return librarypass; } else { return pass; } }
furthermore, provisioning profile must passbook enabled. created new profile app id contains pass type identifier.
ios 7 nice in context. works.
Comments
Post a Comment