gpt4 book ai didi

ios - iOS PASSBOOK-为存折创建多个PKPass时出错

转载 作者:行者123 更新时间:2023-12-01 16:30:30 30 4
gpt4 key购买 nike

我正在使用用于在iOS中创建登机牌的存折功能,可以创建单个登机牌,并且运行良好,但是在尝试创建多个登机牌时,遇到以下问题:

  • 我可以获取计数,但是在回顾
  • 时所有的通行证都被最后一张替换了
  • 选择“全部保存”后,存折应用程序中只有一次通过,即最后一次。

  • 我正在使用以下代码来显示通行证
    -(void) initializeWithMultiPassbookArray:(NSMutableArray *)arrPasses
    {
    NSMutableArray *arrPKPass = [[NSMutableArray alloc] init];

    for(NSString *path in arrPasses)
    {
    NSData *data;

    if(path && path.length)
    {
    data = [[NSData alloc] initWithContentsOfFile:path];

    NSError *error;

    PKPass *passSample = [[PKPass alloc] initWithData:data error:&error];

    if(passSample)
    {
    [arrPKPass addObject:passSample];
    passSample = nil;
    }
    else
    JALog(@"passSample is nil");
    }
    else
    {
    JALog(@"Error occured while fetching pkpass data from cache path");
    }
    }

    if(arrPKPass && arrPKPass.count > 1)
    {
    if(!self.passLibrary)
    self.passLibrary = [[PKPassLibrary alloc] init];

    __weak BookingSuccessfulViewController *self_ = self;
    if(viewPopUpBg)
    {
    [viewPopUpBg removeFromSuperview];
    viewPopUpBg = nil;
    }
    [self.passLibrary addPasses:arrPKPass withCompletionHandler:^(PKPassLibraryAddPassesStatus status) {

    switch (status) {
    case PKPassLibraryDidAddPasses:
    {
    [App_Delegate performSelectorOnMainThread:@selector(RemoveLoader) withObject:nil waitUntilDone:YES];
    if([self_ respondsToSelector:@selector(showAlertFor:withMsg:withTag:)])
    [self_ showAlertFor:SAVED withMsg:@"Your booking details have been added to Passbook." withTag:0];
    break;
    }
    case PKPassLibraryDidCancelAddPasses:
    {

    [App_Delegate performSelectorOnMainThread:@selector(RemoveLoader) withObject:nil waitUntilDone:YES];

    break;
    }
    case PKPassLibraryShouldReviewPasses:
    {
    //[self_ performSelectorOnMainThread:@selector(RemoveLoader) withObject:nil waitUntilDone:YES];
    [App_Delegate performSelectorOnMainThread:@selector(RemoveLoader) withObject:nil waitUntilDone:YES];


    PKAddPassesViewController *vcPKAddPass = [[PKAddPassesViewController alloc] initWithPasses:arrPKPass];
    [vcPKAddPass setDelegate:(id)self_];
    [self_ presentViewController:vcPKAddPass animated:YES completion:nil];
    vcPKAddPass = nil;
    break;
    }
    default:
    break;
    }

    }];
    }
    else if(arrPKPass.count == 1)
    {
    if(viewPopUpBg)
    {
    [viewPopUpBg removeFromSuperview];
    viewPopUpBg = nil;
    }

    [App_Delegate performSelectorOnMainThread:@selector(RemoveLoader) withObject:nil waitUntilDone:YES];

    PKPass *passLocal = [arrPKPass objectAtIndex:0];

    if(passLocal)
    {
    self.currentPass = passLocal;

    //present view controller to add the pass to the library
    PKAddPassesViewController *vcPKAddPass = [[PKAddPassesViewController alloc] initWithPass:passLocal];
    [vcPKAddPass setDelegate:(id)self];
    [self presentViewController:vcPKAddPass animated:YES completion:nil];
    vcPKAddPass = nil;
    }
    }
    else
    {
    JALog(@"arrPKPass is nil");
    }
    }

    最佳答案

    得到了我的回答:

    创建JSON时,每个Pass都应在键“serialNumber”中包含不同的序列号

    还要在“项目”>“目标”>“功能”>“存折”中检查功能

    使用特定标识符选择了pass类型的允许子集。

    这些步骤对我有用。

    希望也能帮助别人。

    谢谢

    关于ios - iOS PASSBOOK-为存折创建多个PKPass时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31872567/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com