Passbook generates PKPass error

I add a save in my application when the iOS6.0 system is working correctly. When the iOS7.1 system error appears.

enter image description here

I check the code found that

PKPass *newPass = [[PKPass alloc] initWithData:passData error:&error];

When generating PKPass in iOS6.0, get the correct PKPass when the iOS7.1 system gets zero.

The error contains the message:

Domain Error = PKPassKitErrorDomain Code = 1 "The skip cannot be read because it is invalid." UserInfo = 0x175cd2f0 {NSUnderlyingError = 0x175c2c10 "more than one field has a telephone key. The field keys must be unique.", NSLocalizedDescription = The gap cannot be read because it is invalid.}

I get the data from the server from the server. Code for example

- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
[self.connectionData appendData:data];
}

After entering data into a file, follow these steps:

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES);
NSString* filePath  = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"pk.pkpass"];

if ([self.connectionData writeToFile:filePath atomically:YES]) {

    if (![PKPassLibrary isPassLibraryAvailable]) {

        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Error"
                                                     message:@"PassKit not available"
                                                    delegate:nil
                                           cancelButtonTitle:@"Pitty"
                                           otherButtonTitles:nil];
        [alert show];
        [alert release];

        return;
    }
}

, , :

    NSString* passFile = [[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES) objectAtIndex:0] stringByAppendingPathComponent:name];

NSString * newPassStr = [[NSString alloc] initWithContentsOfFile:passFile encoding:NSUTF8StringEncoding error:nil];

NSData *passData = [NSData dataWithContentsOfFile:passFile];

NSError* error = nil;
PKPass *newPass = [[PKPass alloc] initWithData:passData error:&error];

, PKPass * newPass, iOS7.1. iOS6 .

- ? .

+4
1

, .

pass.json. backFields auxiliaryFields phone. " ", .

, Passsource. , , kudit ( Passsource) , .

+1

Source: https://habr.com/ru/post/1542426/


All Articles